How to show all rows in the jqGrid?

Viewed 73400

jqGrid exposes a property rowNum where you can set the number of rows to display for each page. How do you set the grid to just display ALL rows?

Right now I'm just setting the rowNum to something really high like <%= int.MaxValue %> but I'm wondering if there is a better way.

15 Answers

if you dont wish to use paging at all then change you server side code to simply return all the rows. dont use the rows parameter at all.

if you want to have the rowlist but also have an option to show all then do something like this in the grid properties

jQuery("#statement_mods").jqGrid({
  rowList:['ALL',30,50,100,200]
});

and then in the serverside code make sure that you ignore the rows parameter if GET['rows']='ALL'

This works:

// Step1 - defines the rows
jqGridOptions.rowList =[10, 50, 100, 500, 'All'];
...
...
// Step2 - Change the 'All' to a meaningful value 
loadComplete: function (data) {
   $(".ui-pg-selbox option[value='All']").val(1000);
}

You can also go into jquery.jqGrid.js and change "rowNum:20" to "rowNum:Some-Really-Large-Number". When you define your jqGrid, don't specify rowNum. Then return your entire dataset back to jqGrid.

loadComplete: function (data) {
                //set our "ALL" select option to the actual number of found records
                $(".ui-pg-selbox option[value='ALL']").val(data.records);
}

This changes the "ALL" option to the actual number of records in the dataset.

Setting rowNum:-1 works for me like, after that it was showing all records but it still has row number option in grid footer like this:

enter image description here

To remove this I just added a css option display none by getting the sector in jquery. Like this

$('#id_tableCell').css('display', 'none');

Note: This css setting should be done when the grid load is completed.

Related