jqgrid 单击双击事件分不清
2015-12-01 11:57
309 查看
jqgrid中单据事件是onSelectRow、双击事件ondblClickRow
但是双击的时候会响应两次onSelectRow然后才响应ondblClickRow
在多选情况下怎么避免不响应onSelectRow而响应ondblClickRow
参考这里:http://stackoverflow.com/questions/7627512/jqgrid-multiselect-limit-the-selection-of-the-row-only-using-the-checkbox
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.
解决方法1:
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
event object, e.target is the DOM element which was clicked. You can get the cell (
$.jgrid.getCellIndex to get the index of the cell insido of the row. The index in the
The corresponding demo you can see
here.
解决方法2:
I would like to suggest easier solution:
但是双击的时候会响应两次onSelectRow然后才响应ondblClickRow
在多选情况下怎么避免不响应onSelectRow而响应ondblClickRow
参考这里:http://stackoverflow.com/questions/7627512/jqgrid-multiselect-limit-the-selection-of-the-row-only-using-the-checkbox
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.
解决方法1:
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
beforeSelectRowis
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 the
colModelshould point to the 'cb' column which contain the checkboxes. So the code could be the following:
beforeSelectRow: function (rowid, e) { var $myGrid = $(this), i = $.jgrid.getCellIndex($(e.target).closest('td')[0]), cm = $myGrid.jqGrid('getGridParam', 'colModel'); return (cm[i].name === 'cb'); }
The corresponding demo you can see
here.
解决方法2:
I would like to suggest easier solution:
beforeSelectRow: function(rowid, e) { return $(e.target).is('input[type=checkbox]'); },
相关文章推荐
- 每天一个linux命令(45):route命令
- 每天一个linux命令(44):ifconfig命令
- Unable to instantiate fragment make sure class name..
- 分布式文件系统]各分布式文件系统比较、适用领域、原理、选型
- Zookeeper入门-Linux环境下异常ConnectionLossException解决
- SpringMVC 表单验证
- Zookeeper入门-Linux环境下异常ConnectionLossException解决
- Zookeeper入门-Linux环境下异常ConnectionLossException解决
- Hibernate:主键生成策略
- git在oschina中的使用
- CSS预处理器们
- 随想16
- git clone Gtk-WARNING **: cannot open display
- Zookeeper ACL权限控制
- for循环的判断条件与内容的list重合,导致for循环一致进行
- 因果关系的倒置(1)
- CF 600E(Lomsat gelral-dfs)
- objc 中的 block
- 集合之hashCode()方法
- LintCode: Fizz Buzz