How to show all rows in the jqGrid?

2019-01-11 00:35发布

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.

14条回答
别忘想泡老子
2楼-- · 2019-01-11 00:58

Even if it still appears in the doc that you cannot set rowNum to -1 as of jqGrid 4.5.4 it works again (maybe in earlier version too).

查看更多
Bombasti
3楼-- · 2019-01-11 00:59

setting rowNum:-1 did the trick for me

查看更多
smile是对你的礼貌
4楼-- · 2019-01-11 01:00

If you have set the pagination on the navbar, you can also access to the total number of rows written on the right-bottom of the grid and then append to the generated RowList option.

Do something like :

    // Get the total number of rows and delete space between numbers (Split the content of the div depending of the language (for me french)

var val=jQuery("#pager_right div").text().split('sur')[jQuery("#pager_right div").text().split('sur').length-1].split(' ').join('');

    // And do the appending if the option isn't already added

if(!$(".ui-pg-selbox option[value='"+val+"']").length > 0)
    jQuery(".ui-pg-selbox").append($('<option></option>').val(val).html(val));
查看更多
三岁会撩人
5楼-- · 2019-01-11 01:00

resolved it with simple change: rowNum: inputDataArray.length

where inputDataArray is the array that I am providing to the Grid.

查看更多
Melony?
6楼-- · 2019-01-11 01:01

In the latest version of jqGrid, you can set rowNum to -1 to instruct the grid to always display all rows:

rowNum: -1

See the latest jqGrid documentation here.

Specifically:

Sets how many records we want to view in the grid. This parameter is passed to the url for use by the server routine retrieving the data. Note that if you set this parameter to 10 (i.e. retrieve 10 records) and your server return 15 then only 10 records will be loaded. Set this parameter to -1 (unlimited) to disable this checking.


Update

Unfortunately this behavior was broken in jqGrid 3.6.3. According to this post from Tony:

Yes, this is true. The reason is the new introduced scroll:1. In the future we will correct this behavior.

So the jqGrid developers are aware of this problem and apparently are planning to fix it in a future release. Unfortunately this post was from over a year ago...

At this time, all I can recommend is that you set rowNum to a very large number to simulate the behavior of -1.


You can also try whatispunk's solution below of using rowNum: ''. However, I tried this on a grid containing local data (loadonce: true). When attemping to sort the rows all of the grid's local data would disappear. So this solution does not seem to work for grids with local data, unless this defect has been fixed in a later version of jqGrid (I tested it on jqGrid 3.8.2). If you have feedback, please post a comment below!


Update - April 16, 2014

According to the jqGrid team this is now fixed:

I have added support to set different display values on pager select box including -1 for all.

I have not had a chance to test to confirm the fix, though. Presumably this change will be in the next release after jqGrid 4.6.0.

查看更多
倾城 Initia
7楼-- · 2019-01-11 01:01

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);
}
查看更多
登录 后发表回答