PDA

View Full Version : How to reset paging toolbar?



devnullable
30 Aug 2011, 11:59 PM
How can I reset paging toolbar when store is reloaded(most likely with different result set)? If user has changed to some other page start and page parameters reflects that. When user makes a new search naturally page should be first one...

arthurakay
31 Aug 2011, 12:09 PM
This usually happens automatically... post some code so I can see what you're doing and offer you a detailed answer.

devnullable
31 Aug 2011, 7:58 PM
myStore.load({
params : {

startDate: Ext.Date.format(myStartDate, 'd.m.Y'),
endDate: Ext.Date.format(myEndDate, 'd.m.Y'),
city: city
},
start: 0
});



Actually it seems to load first page correctly but the page number is not updated to field of paging toolbar.

arthurakay
1 Sep 2011, 9:44 AM
Looking at the API docs for Ext.toolbar.Paging, it looks like you should have your "start" param inside the "params" object:



store.load({
params: {
// specify params for the first page load if using paging
start: 0,
limit: myPageSize,
// other params
foo: 'bar'
}
});

devnullable
4 Sep 2011, 10:21 PM
Looking at the API docs for Ext.toolbar.Paging, it looks like you should have your "start" param inside the "params" object:
I tried and moved start=0 and limit=20 parameters to params object. But now I can see in firebug that request have parameters start=20 and limit=20. Is paging toolbar overriding start and limit parameters in params block?


If I keep those parameters outside params object request has start=0 and limit=20 but paging toolbar is out of sync and shows page 2(or whatever page user has changed to before).

skirtle
5 Sep 2011, 6:28 PM
Don't think load() updates currentPage. Try:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store-method-loadPage

devnullable
5 Sep 2011, 11:16 PM
I tried loadPage but I couldn't set any parameters same way as in load method.

I found this thread http://www.sencha.com/forum/showthread.php?136872-loadpage-1-pagingtoolbar and succeeded by setting first myStore.currentPage = 1 and then calling myStore.load({... Feels little bit dirty though...

skirtle
6 Sep 2011, 12:00 AM
Sorry about that, based my answer on the current online docs which are for version 4.0.6. It seems the second parameter for options wasn't added until after 4.0.2.

devnullable
6 Sep 2011, 1:14 AM
Sorry about that, based my answer on the current online docs which are for version 4.0.6. It seems the second parameter for options wasn't added until after 4.0.2.No problem. Thanks for helping!