tags:

views:

42

answers:

2

I'd like to fix the number of pages in a client side jqGrid to only one page.

Is there any way to do this?

Thanks for answers!

A: 

I am not quite understand why you need what you ask, but technically it is possible to fix the number of pages returned by server inside of jsonReader. For example, the following jsonReader will fix the number of pages to 10 if the server say, that the total number of pages are more as 10:

jsonReader: {
    total: function(obj) {
        if (obj.total > 10) {
            return 10;
        } else {
            return obj.total;
        }
    }
}

I recommend you only use such kind of fixes only as a bug fixing and only if you have no access to the server code.

Oleg
A: 

You can use the scroll option to disable the pager and show all elements in a single "page" on the grid:

Creates dynamic scrolling grids. When enabled, the pager elements are disabled and we can use the vertical scrollbar to load data. When set to true the grid will always hold all the items from the start through to the latest point ever visited. When scroll is set to value (eg 1), the grid will just hold the visible lines. This allow us to load the data at portions whitout to care about the memory leaks. Additionally this we have optional extension to the server protocol: npage (see prmNames array). If you set the npage option in prmNames, then the grid will sometimes request more than one page at a time, if not it will just perform multiple gets.

On the demo page, see the demo under New in version 3.7 | Virtual scrolling for an example.

Justin Ethier