jqGrid multiselect - 仅使用复选框限制行的选择
早上好,我正在开发一个启用多重选择的 jqGrid。
我需要仅使用多重选择框来限制行的选择,而不是通过单击行上的任何位置。 那是因为我需要通过单击某些单元格上的链接来执行一些操作,并且我不会更改活动的多重选择。 我尝试设置 multiboxonly 属性,但这不是我需要的。 我没有找到其他任何东西来定制网格的这个功能。
Good morning, I'm working on a jqGrid that have the multiselection active.
I need to limit the selection of the row only using the multisel box, not by clicking everywhere on the row.
Thats's because I need to do some action by clicking links on some cells and I won't alter the active multiselection.
I tried to set the multiboxonly property, but it's not what I need.
I didn't find anything else to customize this function of the grid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以控制在哪次点击上根据您的自定义 beforeSelectRow 事件处理程序。如果处理程序返回 true,则将选择该行。如果返回 false,则不会选择该行。
beforeSelectRow
的第二个参数是事件对象,e.target 是被单击的 DOM 元素。您可以使用$(e.target).closest('td')
获取点击完成的单元格 ()。然后您可以使用 $.jgrid.getCellIndex 获取单元格的索引行的内西多。
colModel
中的索引应指向包含复选框的“cb”列。因此代码可能如下:相应的演示您可以在此处查看。
You can control on which click the row will be selected with respect of your custom beforeSelectRow event handler. If the handler return true, the row will be selected. If you return false the row will be not selected.
The second parameter of
beforeSelectRow
is event object, e.target is the DOM element which was clicked. You can get the cell (<td>
) in which the click done with$(e.target).closest('td')
. Then you can use $.jgrid.getCellIndex to get the index of the cell insido of the row. The index in thecolModel
should point to the 'cb' column which contain the checkboxes. So the code could be the following:The corresponding demo you can see here.
我想建议更简单的解决方案:
I would like to suggest easier solution:
当 multiselect 设置为 true 时,单击行上的任意位置会选择该行;当 multiboxonly 也设置为 true 时,仅当单击复选框时才进行多重选择。
所以答案是:
When multiselect is set to true, clicking anywhere on a row selects that row; when multiboxonly is also set to true, the multiselection is done only when the checkbox is clicked.
So the answer would be: