3
有沒有適當的方法來將kendo-ui下拉菜單集成到kendo-ui網格的列中?Knockout-kendo.js網格單元格DropDown
這是我曾嘗試使用rniemeyer的Knockout-kendo.js。 裏面的$(document)。就緒:
function statusDropDownEditor(container, options) {
$('<input data-text-field="name" data-value-field="id" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataSource: {
transport: {
read: "/api/Status"
}
}
});
HTML:
<div id="prod-grid" data-bind="kendoGrid: { data: Products, height: 480,
sortable: true, selectable: 'row', scrollable: true, resizable: true, pageable: false,
columns: [
{ field: 'ProdName', title : 'Product Name'},
{ field: 'UnitCost', title: 'Unit Cost'},
{ field: 'TotalAmt', title: 'Batch Total'},
{ field: 'Manufacturer', title: 'Manufacturer'},
{ title: 'Status', editor: statusDropDownEditor}
}>
</div>
但是,它會產生一個錯誤,指出: 未捕獲的錯誤:無法解析綁定。 消息:ReferenceError:categoryDropDownEditor未定義;
此外,我希望有下拉顯示基於產品模型的狀態值。
我建議你不要在綁定中用你的HTML內聯你的'kendoGrid'。海事組織這是不好的做法。它會導致各種問題。保持你的代碼和標記分開。 – Brett