这里是字段:
{ field: "category", title: "Category", width: 100, editor: categoryDropDownEditor },
自定义编辑器:
function categoryDropDownEditor(container, options) {
console.log('used editor')
$('<input data-text-field="category" data-value-field="category" data-bind="value:'+options.field+'"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataSource: {
type: "json",
transport: {
read: "/api/notes/dumpcats"
}
}
})
}
也在 model.fields 中:
category: {
type: "combobox",
editable: true,
validation: { required: true }
},
没有错误,只是空的组合框和输入框,在输入类别时会出错。
未捕获类型错误:对象 [object Object] 的属性“_parse”不是函数
我使用了示例here
最佳答案
问题已解决,正如 Burke Holland 在下面指出的发布答案:
function categoryDropDownEditor(contrainer, options) {
$('<input data-text-field="category" data-value-field="category" data-bind="value:' + options.field + '"/>"')
.appendTo(contrainer)
.kendoComboBox({
index: 0,
placeholder: "Select category",
dataTextField: "category",
dataValueField: "category",
dataSource: {
transport: {
read: {
url: '/api/notes/cats',
dataType: 'json',
type: 'GET',
},
},
schema: {
data: function(reply) {
return reply.rows
},
}
}
})
}
关于ajax - 剑道网格 : combobox field from json data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14057875/