开发者

jqGrid - How to unselect the header row checkbox

Here is the scenario:

1. Select all rows by checking the header row checkbox. 2. Unselect one row. 3. The header row checkbox 开发者_StackOverflow中文版is still checked which is invalid because not all rows are selected.

How can I unselect the hedaer row checkbox? Thanks


You can use resetSelection method. Look at the example prepared for this and this question. The button "Clear Selection" use resetSelection method.


You can do the following:

var grid = $("#ID_OF_YOUR_GRID");

grid.jqGrid({
        //other options
        multiselect: true,
        onSelectRow: function (rowid, status) {     
           var chkSelectAll = $("#ID_OF_THE_HEADER_CHECKBOX_USUALLY_CB_DATA");

           if (chkSelectAll.length && chkSelectAll.is(':checked') && !status) {          
              chkSelectAll.removeAttr('checked');
           }
         }
     });

BTW. You only need this on the older versions of JQGrid. I've checked in version 4.3.1 this works out of the box.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜