How to automatically select the header checkbox in jqGrid?

version – jqGrid 4.6.0

I tried with following 3 ways:

$("#cb_" +'checked', true);


$("#cb_" +;


$("#cb_" +'checked', true);

Header checkbox (select all) is not getting selected.

(Scenario Explanation)

Totally 2 pages in the grid…In page1, I am selecting the header, so all rows get selected and even header is selected..Now going to page 2 and again clicking on previous(that is page1), now the rows are maintaining selected but the header is not being selected..For that in onpaging I had tried the above codes…but the header is not being selected…I checked the condition that if all rows are selected only then the header is being selected..but the code above not working….


onPaging: function (pgButton) {
        var pagerId = this.p.pager.substr(1);
        var newUserValue = $('input.ui-pg-input', "#pg_" + $.jgrid.jqID(pagerId)).val();
        var newValue = 0;
        var currentValue = $("#list").getGridParam('page');
        if (pgButton.indexOf("next") >= 0)
          newValue = ++currentValue;
        else if (pgButton.indexOf("prev") >= 0)
          newValue = --currentValue;
        else if (pgButton.indexOf("last") >= 0)
          newValue = $("#list").getGridParam('lastpage');
        else if (pgButton.indexOf("first") >= 0)
          newValue = 1;
        else if (pgButton.indexOf("user") >= 0)
          newValue = newUserValue;

       $("#list").trigger("reloadGrid", [{ page: newValue }]);
       var recordCount = $("#list").jqGrid('getGridParam', 'reccount');
       var selRowIds = $("#list").jqGrid("getGridParam", "selarrrow");
       if (selRowIds.length == recordCount){
         //$("#cb_list").prop('checked', true);
         //$("#cb_" +;
         //$("#cb_" +'checked', true);
         $("#cb_list").attr('checked', true);
         $("#cb_list").prop('checked', true);

Source: jquery

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.