PDA

View Full Version : Problem Sending Extra Parameters using PagingToolbar buttons (Ext JS 4)



simonr26
9 Dec 2011, 11:43 AM
Hello,
I am using a gridpanel with a paging toolbar contained within the panel's bbar.
When reloading data to store, it is required that parameters are passed to the server,
in order to filter source column data. The store has autoload set to false.


When loading is invoked, e.g. by clicking an item in a tree panel, it is possible
to set the extra parameters in the store command, e.g. as shown below:


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


However when clicking on the paging buttons, I do not know how to pass the extra
parameters?
Please could you advise?


kind regards,
Simon

mitchellsimoens
9 Dec 2011, 3:03 PM
If you need parameters to persist, you need to add the params to the extraParams object on the proxy.

simonr26
9 Dec 2011, 7:52 PM
Thank you Mitchell for reply.


I should have said also that:
I require that the parameters sent to the server following clicking on the paging buttons must be dynamic, i.e. shall change each time - would you know how this can be done? can/how the extraParams be changed?

kind regards,
Simon

simonr26
9 Dec 2011, 8:02 PM
Hello, I should have said also that:
I require that the parameters sent to the server following clicking on the paging buttons must be dynamic, i.e. shall change each time - would you know how this can be done? can/how the extraParams be changed?
kind regards,
Simon

skirtle
10 Dec 2011, 4:48 AM
Use a beforeload listener on the store.

The filters demo uses this technique:

http://dev.sencha.com/deploy/ext-4.0.7-gpl/examples/grid-filtering/grid-filter-local.html

Have a search through FiltersFeature.js for beforeload:

http://dev.sencha.com/deploy/ext-4.0.7-gpl/examples/ux/grid/FiltersFeature.js

simonr26
11 Dec 2011, 5:40 PM
Thank you for your reply.

I have used a beforeLoad listener as below.
The parameters are correctly sent to the server the first time the grid's store is loaded. However,
when I select the paging buttons, the beforeLoad function is called but the parameters are
not sent. Would you know why this might be?


beforeLoad : function (store, options) {
var params = ["football","cricket"];
Ext.apply(options.params, params);
}


kind regards,
Simon

skirtle
12 Dec 2011, 3:41 AM
It should work fine.

The example you've posted is a bit odd. Using Ext.apply with an array?

I suggest adding some console logging for options.params at the end of your beforeLoad handler, check whether it's correct at that point. If it subsequently fails to send the expected request I'd advise stepping through with a debugger, though I can't currently see any way this could happen.