右键单击禁用jqGrid中的行选择 [英] Disable row select in jqGrid on right click

查看:90
本文介绍了右键单击禁用jqGrid中的行选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jqGrid中,我当前使用以下命令禁用行选择:

In jqGrid, I am currently disabling row select with the following:

beforeSelectRow: function() {
     return false;
}

这对左键单击效果很好.但是,我注意到它没有触发beforeSelectRow事件处理程序,并且在右键单击时仍选择该行.这对我来说是个问题,因为我正在实现自定义上下文菜单.

This works fine for left clicking. However, I noticed it's not firing the beforeSelectRow event handler and still selecting the row when I right click. This is a problem for me since I'm implementing a custom context menu.

我可以解决此问题,而问问者本人承认是在这里找到了一个骇客: 是否可以停止jqGrid被选中和/或突出显示的行?

I am able to get around this with what asker himself admitted is a hack found here: Is it possible to Stop jqGrid row(s) from being selected and/or highlighted?

还有其他更简单的方法吗?

Is there any other, less hacky way to do this?

谢谢!

更新

看来这只是子网格的问题.请参考此示例.您会注意到,左键单击不会选择行,而右键单击会选择行.

It appears this is only a problem with subgrids. Please refer to this example. You'll notice left clicking does not select the row but right clicking does.

(我偷偷摸摸地走了出来,从奥列格提供的另一个问题的答案中偷走了这个例子.)

(I took the lazy way out and stole this example from an answer to a different question provided by Oleg.)

推荐答案

如果要禁用行选择,可以配置onSelectRow返回false,这将同时阻止左键单击和右键单击.

If you want to disable the row select, you can config onSelectRow to return false, this will block both left click and right click.

onSelectRow: function() {
     return false;
}

要强制右键单击取消选择行:

To force unselect row on right click:

onRightClickRow: function () {
    grid.jqGrid('resetSelection');
    return false;
}

这篇关于右键单击禁用jqGrid中的行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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