2017-08-28 61 views
1

我有一个kendo网格与编辑按钮里面,我不知道我怎么能得到它的id,因为我需要val,在下面的代码中我已经写了代码编辑如何添加更多功能来编辑?我怎样才能得到Kendo编辑按钮瓦尔

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

          dataSource: dataSource, 
          scrollable: false, 
          toolbar: ["create"], 

          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: 'TurbineId', title: 'TurbineId', width: '120px', hidden: true }, 
            { field: 'device_id', title: 'device_id', width: '120px', hidden: true }, 
            { field: 'ModelProducer', title: 'Producer/Model', hidden: true, editor: modelProducer }, 
            { command: ["edit"], title: " " } 
            ], 
     //        { 
     //         command: [ 
     //{ 
     // name: "Edit", 
     // click: function (e) { 
     //  temp = $(e.target).closest("tr"); //get the row 

     // } 
     //} 
     //         ] 
     //        } 


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

          } 


         }); 
+0

什么意思是“如何添加更多的功能来编辑”,你是指更多的功能,当按钮被点击或? – Adriani6

+0

@ Adriani6 yeas我想尽快点击编辑按钮{do .....} – mrslt

回答

0

由于你没有提供的,当你想要得到的按钮,我创建了一个演示,你可以得到该按钮引用点击编辑按钮时,如何和更多信息。事件是这样的:

edit: function(e) { 
    var $currentButton = $(this.tbody).find('tr[data-uid="' + e.model.uid + '"] td:last .k-button'); 
}; 

Demo

+0

感谢您的演示,但现在如何才能找到这个编辑按钮是否被点击? – mrslt

+0

@mrslt只有点击按钮时才会触发。 – DontVoteMeDown

+0

我在那里更新了我的问题,请看看编辑部分,我已经有一些标签,也可能添加你写的功能? @DontVoteMeDown – mrslt

0

建立kendoGrid时,您可以将点击事件的回调()。在你调用的javascript函数内部可以访问网格的dataItem(它将包含dataSource使用的所有数据)。

$("#turbingrid").kendoGrid({ 
    columns: [ { command: [ { name: "Edit", click: "onClickFunc" ] } ] 
}); 

function onClickFunc(e) { 
    var grid = $("#turbingrid").getKendoGrid(); 
    var data = grid.dataItem($(e.currentTarget).closest("tr")); 
    var deviceId = dataItem.device_id; // or whatever other property 
} 

我假设你试图从你的dataSource行中获得一个值,该行命令按钮被点击。