剑道电网:如何与角使用时从ComboBox电池模板获得所选项目 [英] Kendo Grid: how to get the selected item from a Combobox cell template when using with Angular
问题描述
我有我使用的角度范围内其中剑道网格,并有一个字段的组合框,具有编辑器设置为以下功能...
I have a Kendo grid which I am using within Angular, and have a field with a combo box, that has the editor set to the following function...
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对象的列表...
And data is a list of simple json objects...
[
{code: 'code1', description: 'desc1'}
{code: 'code2', description: 'desc2'}
[
在网格数据中的每个字段被绑定到相同的对象(即用code和描述字段)
Each field in the grid data is bound to the same objects (ie with a code and description field)
我一个previous后,得到排序和筛选工作,我需要一个字段绑定到显示器领域...
I a previous post, to get sorting and filtering working I need to bind a field to the display field...
{
field: "Category.description",
title: "Category",
editor: comboCellTemplate,
template: "#=Category.description#"
},
当我这样做,组合框似乎电网的字段设置为code。
我怎样才能得到这个网格数据集整个数据对象(即{code,说明})
When I do this, the combo box seems to set the field of the grid to the code. How can I get this to set the grid data to the whole data object (ie the {code, description})
我曾尝试加入 - 变更处理程序来做到这一点。
I have tried adding a on - change handler to do this
input.on('change', function () {
var val = input.val();
//var dataItem = input.dataItem();
options.model.set(options.field, val + 'xx');
});
但看不到如何从组合获得了选择项
but can't see how to get the "selected Item" from the combo
我似乎没有能够找到这在帮助(特别是采用了棱角分明的时候)
I don't seem to be able to find this in the help (in particular when using Angular)
在这里任何帮助将大大AP preciated。
问候,彼得
Any help here would be greatly appreciated. regards, Peter
推荐答案
我觉得你可以简单地添加一个变化处理程序编辑器,并从那里设置:
I think you can simply add a change handler to the editor and set it from there:
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,
change: function () {
options.model.set(options.field, this.dataItem());
}
});
}
这篇关于剑道电网:如何与角使用时从ComboBox电池模板获得所选项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!