roro
roro

Reputation: 213

Kendo grid not detecting keydown or keypress event

I have something like this

HTML:

<div class="outer"> 
   <div class="myKendoGrid"> </div>
</div> 

JS:

$(function () {
     var grid = $(".myKendoGrid").data("kendoGrid");
     grid.table.on("keypress", function (e) {
          console.log('pressed');
     });
 });

Problem: Can't detect keypress or keydown in the grid.

Referenced from: http://www.telerik.com/forums/grid-row-delete-by-using-keyboard-delete-key

Upvotes: 0

Views: 4865

Answers (2)

Vijai
Vijai

Reputation: 2507

Try with ID for DIV:

               $("#KGrid").on("click", ".myKendoGrid", function () {
...

}
<div id="KGrid" class="myKendoGrid"> </div>

Upvotes: 0

DinoMyte
DinoMyte

Reputation: 8868

You can't register a keypress or keydown event until you initiate a click event. Try the following.

$(".myKendoGrid").on("click", "table", function (e) {
        window.onkeydown = function (event) {
                alert("key pressed");
            }
});

Upvotes: 2

Related Questions