javascript 如何处理 Kendo UI Grid 行双击事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20842058/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 19:26:20  来源:igfitidea点击:

How to handle a Kendo UI Grid row double-click event

javascriptjquerykendo-uikendo-gridkendo-asp.net-mvc

提问by Water Cooler v2

I have a selectable KendoUI grid in my MVC app. I want to do something when the user double-clicks on the grid.

我的 MVC 应用程序中有一个可选择的 KendoUI 网格。我想在用户双击网格时做一些事情。

I don't see a double-click event for the grid.

我没有看到网格的双击事件。

How may I handle the double-click event when there is none exposed?

当没有暴露时,我该如何处理双击事件?

回答by EfrainReyes

Use the standard double click event. The first click will select the grid row, adding a .k-state-selectedclass to it, and the second click will trigger the double click event.

使用标准的双击事件。第一次点击会选中网格行,.k-state-selected给它添加一个类,第二次点击会触发双击事件。

$("#yourgridname").on("dblclick", "tr.k-state-selected", function () {
    // insert code here
});

回答by fangxing

You can also use dataBound

你也可以使用 dataBound

dataBound: function (e) {
   var grid = this;
   grid.tbody.find("tr").dblclick(function (e) {
      var dataItem = grid.dataItem(this);
      ...
    });
}

from http://www.telerik.com/forums/double-click-on-grid-row-with-angular

来自http://www.telerik.com/forums/double-click-on-grid-row-with-angular

回答by Salar

With kendoHelpersyou can get the dataItem of the row. https://github.com/salarcode/kendoHelpers

使用kendoHelpers,您可以获得该行的数据项。 https://github.com/salarcode/kendoHelpers

kendoHelpers.grid.eventRowDoubleClick (theGrid, 
    function(dataItem){
        // do stuff with dataItem
    });

It also has eventCellDoubleClickwhich works on cells.

它还eventCellDoubleClick对细胞起作用。

回答by jpllosa

Here's another way to handle it:

这是处理它的另一种方法:

var grid = $('#myGrid').kendoGrid({
    columnMenu: true,
    filterable: true,
    selectable: true,
    // and many more configuration stuff...
}).data('kendoGrid');

grid.tbody.delegate('tr', 'dblclick', function() {
    var dataItem = grid.dataItem($(this));
    // do whatever you like with the row data...
});