jqgrid 单击双击事件分不清

1 篇文章 0 订阅
1 篇文章 0 订阅

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 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 the colModel should 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]');
},

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值