Avoid right click on kendo grid

匆匆过客 提交于 2019-12-12 00:16:01

问题


This is my grid:

$("#myHtmlTable1").kendoGrid({
    dataSource: {
        pageSize: 18
    },
    scrollable: false,
    sortable: true,
    filterable: true,
    selectable: true,
    pageable: {
        input: false,
        numeric: false
    },
    change: function () {
        // MY LOGIC
    },
    columns: [
    {
        field: "Col1",
        width: 40
    },
    {
        field: "Col2",
        width: 250
    },
    {
        width: 40,
        field: "Col3"
    },
    {
        width: 150,
        field: "Col4"
    }
    ]
});

When I clic a row I get the row text and I put it in another textbox. But I want to do this only with left button mouse so that I can see the source code page using the right clic over the grid.


回答1:


You can attach the following keydown handler to the tbody element of the Grid when the document event is triggered to prevent the right click mousedown event from bubling and thus avoid the Grid reacting to it.

$(function(){
    $('#myHtmlTable1').data('kendoGrid').tbody.on('mousedown',function(e){
        if(e.button==2){
            e.stopImmediatePropagation()
        }
    })
})


来源:https://stackoverflow.com/questions/14279285/avoid-right-click-on-kendo-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!