Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

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

like image 298
Water Cooler v2 Avatar asked Dec 30 '13 15:12

Water Cooler v2


Video Answer


4 Answers

You can also use 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

like image 121
fangxing Avatar answered Oct 10 '22 21:10

fangxing


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

Since v3.0, delegate has been deprecated. You can use on, like so:

grid.tbody.on('dblclick', 'tr', function() {
    var dataItem = grid.dataItem($(this));
    // do whatever you like with the row data...
});
like image 33
jpllosa Avatar answered Oct 10 '22 22:10

jpllosa


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

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

It also has eventCellDoubleClick which works on cells.

like image 45
Salar Avatar answered Oct 10 '22 23:10

Salar


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

$("#yourgridname").on("dblclick", "tr.k-state-selected", function () {
    // insert code here
});
like image 24
EfrainReyes Avatar answered Oct 10 '22 23:10

EfrainReyes