2015-03-31 86 views
0

我有一個可編輯字段的網格。如果我添加一條新記錄,我會將所選條目看作[對象對象]。但是我想要的是條目的「文本」。如何實現這一目標?如何訪問Kendo UI Grid DropDown-Editor的選定文本/值?

<!DOCTYPE html> 
    <html> 
    <head> 
     <link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.318/styles/kendo.common.min.css"> 
     <link rel="stylesheet" href="http://cdn.kendostatic.com/2015.1.318/styles/kendo.default.min.css"> 
     <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> 
     <script src="http://cdn.kendostatic.com/2015.1.318/js/kendo.all.min.js"></script> 
    </head> 
    <body> 
    <h3>Kendo UI Grid DropDown-Editor: How to access the selected text/value?</h3> 
    <div id="grid"></div> 
    <script> 
     function nameDropDownEditor(container, options) { 
      $('<input data-text-field="nameText" data-value-field="nameValue" data-bind="value:' + options.field + '"/>') 
       .appendTo(container) 
       .kendoDropDownList({ 
        dataSource: [ 
         { nameText: "Jane", nameValue: 100 }, 
         { nameText: "Mike", nameValue: 200 }, 
         { nameText: "Harry", nameValue: 300 } 
        ], 
       }); 
     } 

     $("#grid").kendoGrid({ 
     toolbar: ["create"], 
     columns: [ 
      { field: "id" }, 
      { field: "name", editor: nameDropDownEditor }, 
      { field: "age" } 
     ], 
     dataSource: [ 
      { id: 3030, name: "Jane", age: 30 }, 
      { id: 5353, name: "Harry", age: 53 } 
     ], 
     editable: "popup" 
     }); 
    </script> 
    </body> 
    </html> 

該截圖顯示選擇後的結果: http://i.imgur.com/PEhRt47.png

回答

0

您是否嘗試過給下拉的ID和綁定到保存事件:

...格標記

.Events(events => events.Save("Grid_Save") 

並保存事件

function Grid_Save(e) { 
    var nameValue = $("#dropdownName").data().kendoDropDownList.value(); 
     //do something with the value 
}