我有一个在 Angular 中使用的 Kendo 网格,并且有一个带有组合框的字段,该字段将编辑器设置为以下功能...
function comboCellTemplate(container, options) {
var input = $('<input name="' + options.field + '" />')
input.appendTo(container)
var combobox = input.kendoComboBox({
autoBind: true,
filter: "contains",
placeholder: "select...",
suggest: true,
dataTextField: "description",
dataValueField: "code",
dataSource: data,
});
数据是一个简单的 json 对象列表......
[
{code: 'code1', description: 'desc1'}
{code: 'code2', description: 'desc2'}
[
网格数据中的每个字段都绑定到相同的对象(即带有代码和描述字段)
我在上一篇文章中,为了进行排序和过滤工作,我需要将一个字段绑定到显示字段......
{
field: "Category.description",
title: "Category",
editor: comboCellTemplate,
template: "#=Category.description#"
},
当我这样做时,组合框似乎将网格字段设置为代码。
我怎样才能将网格数据设置为整个数据对象(即{code,description})
我尝试添加一个 on-change 处理程序来执行此操作
input.on('change', function () {
var val = input.val();
//var dataItem = input.dataItem();
options.model.set(options.field, val + 'xx');
});
但看不到如何从组合中获取“选定的项目”
我似乎无法在帮助中找到这个(特别是在使用 Angular 时)
任何帮助将不胜感激。
问候,彼得