PDA

View Full Version : navigate to the first page after grid sorting



reecegwt
12 Nov 2009, 8:31 PM
Hi,

How can i navigate to the first page after sorting the grid in a different page.

the following code goes to the first page but ,it first goes to the current page and then loading the first page...

products.addListener(Store.Sort, new Listener<BaseEvent>()
{
public void handleEvent(BaseEvent be)
{
if (toolBar != null) {
toolBar.first();
}
}
});


Thanks
reece

Arno.Nyhm
13 Nov 2009, 6:54 AM
maybe the Store.sort triggers a refresh on the current grid. maybe you can cancel this event?

reecegwt
15 Nov 2009, 1:57 PM
Thanks for ur reply...can u please explain in more detail

Arno.Nyhm
17 Nov 2009, 6:34 AM
did you do remote sorting? otherwise it makes no sense to go to the first page.

reecegwt
17 Nov 2009, 12:54 PM
yes,i do the remote sorting.
loader.setRemoteSort(true);


Thanks

Arno.Nyhm
18 Nov 2009, 6:38 AM
i have something like this:

but because of that the BeforeSort event does not include the sorting information there is nothing to remember for a new sorting :-(

so i dont know what to do in this case to apply the new sort but to avoid the reload of the page. in my test this goes to the first page, but dont have the sorting :-(


i have this ugly code - i dont know if i am on the right way. i feel i am not. but maybe it gives you some starting point for you.



final Listener<LoadEvent> cancelListener = new Listener<LoadEvent>() {

public void handleEvent(LoadEvent be) {
be.setCancelled(true);
}
};

store.addListener(Store.BeforeSort, new Listener<StoreEvent>() {

public void handleEvent(StoreEvent be) {
if (pagingToolBar.getActivePage() > 1) {
((ListStore) be.getStore()).getLoader().addListener(Loader.BeforeLoad, cancelListener);
((ListStore) be.getStore()).addListener(Store.DataChanged, new Listener<StoreEvent>() {

public void handleEvent(StoreEvent be) {
((ListStore) be.getStore()).getLoader().removeListener(Loader.BeforeLoad, cancelListener);
((ListStore) be.getStore()).removeListener(Store.DataChanged, this);
if (pagingToolBar.getActivePage() > 1) {
pagingToolBar.first();
}
}
});

}
}
});