我有 2 个文件:customer.js
和add-customer-template.html
. 有一个网格,add-customer-template.html
如下所示。
<div id="leadsGrid" data-role="grid"
data-bind="source: leadsDS"
date-scrollable="true"
data-editable="popup"
data-toolbar="['create']"
data-columns='[
{
field: "salesPerson", title: "Sales Person",
editor: "salesPersonDropDownEditor",
template: "#= getSalesPersonName(salesPerson)#"
},
{field: "date", title: "Date", format: "{0:MM-dd-yyyy}"},
{field: "expectedDate", title: "Expected Date", format: "{0:MM-dd-yyyy}"},
{field: "expectedIncome", title: "Expected Income", format: "{0:c}"},
{field: "details", title: "Details"},
{field: "description", title: "Description"},
{command: ["edit", "destroy"], title: " "}]'>
</div>
并customer.js
具有2个功能salesPersonDropDownEditor
,getSalesPersonName
如下所示。
var salesPersonDropDownEditor = function(container, options) {
$('<input data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
dataTextField: "salesPersonName",
dataValueField: "salesPersonID",
dataSource: new kendo.data.DataSource({
transport: {
read: {
url: "../public/js/salesPersons.json",
dataType: "json"
}
}
})
});
}
var getSalesPersonName= function(salesPersonID) {
for (var idx = 0, length = customerAdd.salesPersonData.length; idx < length; idx++) {
if (customerAdd.salesPersonData[idx].CategoryID === customerAdd.salesPersonData.salesPersonID) {
return customerAdd.salesPersonData[idx].salesPersonName;
}
}
}
我想在列上显示下拉列表,sales person
但我收到错误salesPersonDropDownEditor
未定义。当我在周围添加“”时,salesPersonDropDownEditor
它不会引发错误。现在它的抛出错误getSalesPersonName
没有定义。
从网格编辑时如何调用这些函数并显示下拉列表???