Kendo网格没有检测到keydown或keypress事件

时间:2015-11-11 21:45:17

标签: jquery kendo-ui kendo-grid keypress keydown

我有类似的东西

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

问题:无法检测网格中的按键或按键。

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

2 个答案:

答案 0 :(得分:1)

在发起点击事件之前,您无法注册按键或键控事件。请尝试以下方法。

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

答案 1 :(得分:0)

尝试使用ID进行DIV:

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

}
<div id="KGrid" class="myKendoGrid"> </div>
相关问题