PDA

View Full Version : paging grid params



nar
6 Aug 2009, 6:19 AM
One of my grids is loaded by sending several filter options that modify a db query, without these params the query cannot be constructed. In adding paging I have found that while I load the grid with the needed params the first time it does not send the orginal params for each page click. Is there a better way to do this than attaching a listener to a beforeload event and moding baseparams each time?

My initial store load:


store.load({params: {filter: filter, data: data, start:0, limit:25}});

carol.ext
6 Aug 2009, 6:26 AM
[Edit] Oops, I see the end of your post mentions baseParams, why do you need to modify each time ?


Look at baseParams and setBaseParam in Store API (http://extjs.com/deploy/dev/docs/?class=Ext.data.Store).

Also, the Grid FAQ (http://extjs.com/learn/Ext_FAQ_Grid) can help with these and many other questions.

nar
6 Aug 2009, 6:28 AM
I know I could use setbaseparams on a click of the paging toolbar, im wondering if there is a better builtin way to use the params that were sent in the store in the last request.

nar
6 Aug 2009, 6:31 AM
My server is expecting filter and data each time along with start and limit, filter and data are not static they change based on the view. So I load my grid during the initial load with filter, data, start and limit, now someone clicks a page button and filter and data are not included in the next request sent. It seems like there should be some built in method of using the same params that were sent the time before without having to create a listener and set and modify base params on every click.

Condor
6 Aug 2009, 6:33 AM
You could also do this:

Ext.override(Ext.PagingToolbar, {
doLoad : function(start){
var o = {}, pn = this.getParams();
o[pn.start] = start;
o[pn.limit] = this.pageSize;
if(this.fireEvent('beforechange', this, o) !== false){
var options = Ext.apply({}, this.store.lastOptions);
options.params = Ext.applyIf(o, options.params);
this.store.load(options);
}
}
});
to make the paging toolbar reuse all load options except start and limit parameters.

nar
6 Aug 2009, 6:34 AM
Perfect Condor, would be great to see that built in =0

Condor
6 Aug 2009, 7:10 AM
Made a feature request (http://extjs.com/forum/showthread.php?t=76809) for it.

carol.ext
6 Aug 2009, 7:51 AM
Are you using remote sorting? Wouldn't that have an issue with params too?

W3Design
28 Sep 2009, 1:50 AM
Thanx a lot Condor this works perfectly. Really hope they include it ;)

Been struggling for hours trying to get the paging working with my filtering =P~

pym
4 Oct 2012, 2:27 PM
Thanks that works perfectly.