Kendo ui 网格编辑模式下的剑道UI下拉列表
基本上,我有一个剑道UI下拉列表作为我的第一个网格列,名为instrumentName 在弹出编辑模式下,我可以在下拉列表中看到正确的instrumentName,但当我更改值时,有一个问题: 一旦我选择了一个新仪器,仪器ID就会显示在背景的网格上。更新的仪器名称应显示在网格上 一旦我点击更新,它不会显示仪器名称,而是显示仪器ID,它是一个数字 一些代码片段:Kendo ui 网格编辑模式下的剑道UI下拉列表,kendo-ui,kendo-grid,Kendo Ui,Kendo Grid,基本上,我有一个剑道UI下拉列表作为我的第一个网格列,名为instrumentName 在弹出编辑模式下,我可以在下拉列表中看到正确的instrumentName,但当我更改值时,有一个问题: 一旦我选择了一个新仪器,仪器ID就会显示在背景的网格上。更新的仪器名称应显示在网格上 一旦我点击更新,它不会显示仪器名称,而是显示仪器ID,它是一个数字 一些代码片段: instrDropDown.value(e.model.instrumentId); nodeGrid = $("#curvesGr
instrDropDown.value(e.model.instrumentId);
nodeGrid = $("#curvesGrid").kendoGrid({
dataSource: new kendo.data.DataSource({ ... });
columns: [
{
field: "instrumentName",
editor: instrumentsDropDownEditor, template: "#=instrumentName#"
},
{
field: "instrumentTypeName"
},
edit: function(e){
var instrDropDown = $('#instrumentName').data("kendoDropDownList");
instrDropDown.list.width(350); // widen the INSTRUMENT dropdown list
if (!e.model.isNew()) {
instrDropDown.value(e.model.instrumentId);
}
}
});
下面是我的下拉列表模板编辑器:
function instrumentsDropDownEditor(container, options) {
// INIT INSTRUMENT DROPDOWN !
var dropDown = $('<input id="instrumentName" name="instrumentName">');
dropDown.appendTo(container);
dropDown.kendoDropDownList({
dataTextField: "name",
dataValueField: "id",
dataSource: {
type: "json",
transport: {
read: "/api/breeze/GetInstruments"
},
},
pageSize: 6,
//select: onSelect,
change: function () { },
close: function (e) {
},
optionLabel: "Choose an instrument"
}).appendTo(container);
}
我需要在更改下拉列表时做些特殊的操作吗
谢谢。
Bob数据字段值是将要保存为DropDownList值的值。如果要保存名称,则应将dataValueField定义为名称
关于背景更新,这是默认行为,因为这是一个可观察对象,因此更改会自动传播。如果您不想这样做,您可能应该尝试在下拉列表中使用假变量,并在保存事件中将其复制到实际字段。你真的需要这个吗