PDA

View Full Version : Paging bar not proper after remote Sort



deniz.baby
3 Mar 2015, 4:27 AM
Hi ,
In our application we are using one Grid panel, store & paging bar(With remote sort set as true - in EXT js 5.1.0 version ). For example : we have 4 pages of record in the grid and we navigated to 3rd page using paging bar, After that when we sort by clicking header, sorting (remote) will happen and the records will be loaded correctly. The problem we are facing is that the paging bar still show as 3rd page. but the record loaded will be of the first page. Please let us know how to fix this issue in any of the ways mentioned below.
How to reset the page number to show the first page
The records should be loaded should be of 3rd page.
Please help.

Thanks,
Deniz

joel.watson
9 Mar 2015, 11:34 AM
Hi ,
In our application we are using one Grid panel, store & paging bar(With remote sort set as true - in EXT js 5.1.0 version ). For example : we have 4 pages of record in the grid and we navigated to 3rd page using paging bar, After that when we sort by clicking header, sorting (remote) will happen and the records will be loaded correctly. The problem we are facing is that the paging bar still show as 3rd page. but the record loaded will be of the first page. Please let us know how to fix this issue in any of the ways mentioned below.
How to reset the page number to show the first page
The records should be loaded should be of 3rd page.
Please help.

Thanks,
Deniz

Hi Deniz--

With remote sorting, you're going to get the page of records that falls into the page/limit/start combination which was sent to the server. So for example, if you have a pageSize of 25 and you're on the third page, the remote sort request is going to include params like so:

page=3
start=50
limit=25
sort=title
dir=ASC
Your server is responsible for sending back the data set that matches those criteria. For example, if you're sorting by "title", it should give you the records whose indexes in the datasource that, in sorted order, fall between 50 and 75.

So this is behaving as expected since, in terms of the entire data set, no record belongs to any particular "page" exclusively.

If you need to sort the records within the current page, turn off remote sorting. But ultimately, the data that's displayed on any particular page of the grid is the responsibility of the server to provide correctly. Ext JS has absolutely no idea about what records should be where...it merely displays what it's given, trusting that the remote 'handshake" with the server produces the correct results. If the data in the page is not correct, it's almost certainly because the server has not returned the correct data based on the request that was made.

I hope that helps! Thanks!
Joel

yeghikyan
9 Mar 2015, 12:45 PM
add something like this in the grids initComponent:




this.getStore().on('beforesort', function() {
this.down('pagingtoolbar').moveFirst();
}, this);

deniz.baby
17 Mar 2015, 5:07 AM
Thanks yeghikyan.