2013-11-25 86 views
1

基本上我有一个Kendo UI Dropdownlist作为我的第一个网格栏名为“instrumentName” 在弹出式编辑模式下,我可以在下拉列表中看到正确的instrumentName,但是当更改值:在网格编辑模式中的Kendo UI下拉列表

只要我选择一个新仪器 - 仪器ID显示在网格上(在背景中)。更新后的INSTRUMENT NAME应显示在网格上。

一旦我点击更新,它不显示仪器名称,而是仪器ID(这是一个数字)。

一些代码片段:

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); 
} 

我需要做任何事情的下拉的变化特别?

感谢。 鲍勃

回答

0

dataFieldValue是什么将被保存为价值DropDownList。如果您想要保存name,则应将dataValueField定义为name

关于后台更新是默认行为,因为这是一个ObservableObject,因此更改会自动传播。如果你不想要这个,你可能应该尝试使用假冒变量作为下拉菜单,并在save事件中将其复制到实际字段中。你真的需要这个吗?

相关问题