在剑道网格中获取点击事件 [英] getting the click event in a kendo grid

查看:103
本文介绍了在剑道网格中获取点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获得Kendo Grid的点击事件,这样我就可以将东西绑定到shift和ctrl点击。我无法使用Kendo提供的固有多选,因为它不支持拖放操作。当我在dataBound事件后创建一个函数时,我的函数被点击时调用,但它不是典型的点击事件。

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

grid.dataBound = onDataBound;

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

有什么想法?提前致谢。

解决方案

在初始化 Grid



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

您可以使用:


  • e.ctrlKey 用于检测是否按下 ctrl
  • e.altKey 用于检测是否按下 alt
  • e.shiftKey 用于检测是否按下 shift


    如果您只想检测点击您可以用tbody甚至td替换table



    Jsfiddle示例


    I'm trying to get the click event for a Kendo Grid so I can bind stuff to shift and ctrl clicking. I can't use the inherent multiselect Kendo provides because it doesn't support drag and drop. When I create a function after the dataBound event, my function gets called on clicking, but it's not the 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.

    解决方案

    After initializing the Grid you should bind a 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.ctrlKey for detecting if ctrl is pressed.
    • e.altKey for detecting if alt is pressed.
    • e.shiftKey for detecting if shift is pressed.

    If you want to detect click only in the body of the table, you can replace "table" by "tbody" or even "td".

    Jsfiddle example.

    这篇关于在剑道网格中获取点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆