2017-07-26 6 views
0

私のグリッドはajaxコールでバインドされます。編集する行を選択すると、「Device_Type」という名前のフィールドがあり、選択した行のデバイスタイプの値を送信します。ポップアップエディタでドロップダウンリストを埋めるためにAjaxを使って、どうすればその関数を書くことができますか?グリッド内で選択した行の機能を作成

$("#turbingrid").kendoGrid({ 
         // debugger; 

         dataSource: dataSource, 
         scrollable: false,       
         columns: [ 
           { field: 'DeviceIP', title: 'DeviceIP', width: '100px', id: 'DeviceIP' }, 
           { field: 'Producer', title: 'Producer', width: '80px', editor: ProductNameDropDownEditor, }, 
           { field: 'Model', title: 'Model', width: '220px' }, 
           { field: 'DeviceType', title: 'DeviceType', width: '100px',editor: deviceTypesList }, 
           { field: 'Description', title: 'Description', width: '220px' }, 
           { field: 'Username', title: 'Username', width: '120px' }, 
           { field: 'Password', title: 'Password', width: '100px' }, 
           { field: 'PublicIP', title: 'PublicIP', width: '120px' }, 
           { field: 'device_id', title: 'device_id', width: '120px',hidden:true }, 
           { command: ["edit"], title: " " }], 
         editable: "popup", 
         //edit: 
         // function() { 
         //  document.getElementsByName("DeviceIP")[0].disabled = true; 

         // }, 

          edit: function(e) { 
           e.container.find("label[for='device_id']").parent().hide(); 
           e.container.find("div[data-container-for='device_id']").hide(); 
          }                     
        }); 

答えて

1

1行のみを選択する機能を提供している場合、下の関数は列の配列と割り当てられた値を返します。

$("#turbingrid").click(function(){ 
     var grid = $("#grid").data("kendoGrid"); 

     var selectedItem = grid .dataSource._data 
     console.log(selectedItem); 
    }); 

http://dojo.telerik.com/EpeROQ

編集(質問に対応するために)...私の実装の作業例で道場を参照してください:

function select(e){ 
    var selected = $.map(this.select(), function(item) { 
     return $(item); 
    }); 

    console.log(selected) 
} 

あなたのグリッドの作成は、この

のようになります。
$("#turbingrid").kendoGrid({ 
         // debugger; 

         dataSource: dataSource, 
         scrollable: false,       
         columns: [ 
           { field: 'DeviceIP', title: 'DeviceIP', width: '100px', id: 'DeviceIP' }, 
           { field: 'Producer', title: 'Producer', width: '80px', editor: ProductNameDropDownEditor, }, 
           { field: 'Model', title: 'Model', width: '220px' }, 
           { field: 'DeviceType', title: 'DeviceType', width: '100px',editor: deviceTypesList }, 
           { field: 'Description', title: 'Description', width: '220px' }, 
           { field: 'Username', title: 'Username', width: '120px' }, 
           { field: 'Password', title: 'Password', width: '100px' }, 
           { field: 'PublicIP', title: 'PublicIP', width: '120px' }, 
           { field: 'device_id', title: 'device_id', width: '120px',hidden:true }, 
           { command: ["edit"], title: " " }], 
         editable: "popup", 
         selectable : true, 
         change : select, 
         //edit: 
         // function() { 
         //  document.getElementsByName("DeviceIP")[0].disabled = true; 

         // }, 

          edit: function(e) { 
           e.container.find("label[for='device_id']").parent().hide(); 
           e.container.find("div[data-container-for='device_id']").hide(); 
          }                     
        }); 

編集2: このイベントを実装する方法のアイデアを得るのに役立つかもしれないので、少し修正したDojoを見てください。 console.log http://dojo.telerik.com/osIHU

+0

どのように私は、以下のリンクのポップアップエディタで「商品名」の値を取得することができますhttp://dojo.telerik.com/UfeYat – mortezasol

+0

@mortezasolを参照してくださいを参照して、開発者ツールを開くことを確認してください私の更新された答え – Adriani6

関連する問題