jqGrid multiselect - limit the selection of the row only using the checkbox

后端 未结 3 1579
我在风中等你
我在风中等你 2020-12-09 00:29

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 eve

3条回答
  •  粉色の甜心
    2020-12-09 00:51

    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.

提交回复
热议问题