开发者

jqGrid - How to unselect the header row checkbox

开发者 https://www.devze.com 2023-02-03 21:42 出处:网络
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
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

精彩评论

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