1
Here is the scenario:

1. Select all rows by checking the header row checkbox. 2. Unselect one row. 3. The header row checkbox is still checked which is invalid because not all rows are selected.

How can I unselect the hedaer row checkbox? Thanks

Darren
  • 11
  • 1
  • 2

2 Answers2

7

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

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • resetSelection will unselect all of the rows. What we need to do is unselecte the header checkbox, but leave the rows that are currentely selected as selected. – Darren Jan 13 '11 at 20:50
  • @Darren: In the case you should get ids of the current selected rows with `getDataIDs`, call `resetSelection` and then call `setSelection` for all previously selected ids. See code executed on click to `"Select All"` button in the example http://www.ok-soft-gmbh.com/jqGrid/DataToMultiSelect2.htm. After small modification you will have what you need. – Oleg Jan 13 '11 at 20:58
0

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.

Martijn B
  • 4,065
  • 2
  • 29
  • 41