jqgrid 单击双击事件分不清

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 () 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]');
},

你可能感兴趣的:(jqgrid,单击,双击)