PDA

View Full Version : paging and sorting in grid



raj_plays
15 Aug 2010, 11:38 PM
..

raj_plays
17 Aug 2010, 11:13 AM
Hi,
I have a GridPanel with a PagingToolbar.
I want the sorting to be done on "name" on the first load and on "id" on reloads(i.e. when a record is added or deleted).
The problem is that the sorting is always done on "name"(even on reloads).
Here is the code



var Grid1DataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'UserService.asmx/get', method: 'POST'}),
reader: new Ext.data.XmlReader({ record: 'Table',totalProperty: 'total',idProperty: 'id'}, Record1),
sortInfo:{field: 'name', direction: "ASC"},
remoteSort: true
});
......
Grid1.getStore().load({params: {start: 0, limit: pageSize}});

After a record is added/deleted, I reload like this...
Grid1DataStore.reload({params: {sort: 'email', dir: 'DESC', start: 0, limit: pageSize}});

Please help..

raj_plays
18 Aug 2010, 6:31 AM
Can someone reply to this please?
I need to sort the grid dtore on a different column after reload.

Condor
18 Aug 2010, 6:45 AM
Passing the sort and dir in parameters won't work. You'll have to change store.sortInfo

raj_plays
18 Aug 2010, 11:46 PM
Thank you, Condor.
Can I use store.setDefaultSort('email','DESC'); instead of store.sortInfo ?
It seems to work.

Condor
18 Aug 2010, 11:48 PM
Yes, using setDefaultSort is even better.