Getting a click event in a kendo grid

I am trying to get a click event for a Kendo grid so that I can bind things to shift and press ctrl. I cannot use the Kendo built-in multi selector because it does not support drag and drop. When I create a function after the dataBound event, my function is called when clicked, but this is not a typical click event.

var onDataBound = function () {
    selectItem.apply(this);
}

grid.dataBound = onDataBound;

var selectItem.apply = function (e) {
    console.log(e);
}

Any thoughts? Thanks in advance.

+4
source share
3 answers

After initialization, Gridyou must bind the handler to the click event.

Example:

$("#grid").on("click", "table", function(e) {
    console.log("clicked", e.ctrlKey, e.altKey, e.shiftKey);
});

You can use:

  • e.ctrlKeyto detect depression ctrl.
  • e.altKeyto detect depression alt.
  • e.shiftKeyto detect depression shift.

, "table" "tbody" "td".

Jsfiddle.

+8

dataBound :

grid = $("#grid").kendoGrid({
    ...
    ,dataBound=onDataBound
});

var onDataBound = function(e)
{
    $("#grid").find("tr").click(selectItem.apply);
};

var selectItem.apply = function (e) {
    var dataItem = $("#grid").data("kendoGrid").dataItem(this);
    if(e.ctrlKey)
       alert('Ctrl + click on ' + dataItem.column1);
}

dataItem - , .

+2

, , , , . , ( /), . click - , :

$("#grid tbody").find("tr").click(addYourFunctionHere);
0

All Articles