PDA

View Full Version : Combobox - Passing extra params besides limit, query, page, start...



mvosantos
23 Apr 2012, 7:11 AM
Hi folks.
I would like to know if I´m able to pass other params bisedes the defaults ones.
For example, I have my entities models, my entity might be a customer, a sponsor, a employer and whatever...
I would like to pass the param entityType, so for instance:



_dc
1335193454115


limit
25


page
1


query
some test


start
0


entityType
customer

friend
23 Apr 2012, 9:02 AM
You can do this in a store's beforeload (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store-event-beforeload) event or via extraParams (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.Ajax-cfg-extraParams) on a store's proxy.

The beforeload event lets you dynamically pass any parameters each time the event fires. You would do this by directly accessing operation.params, where operation is automagically passed to the beforeload event.

The proxy.extraParams property is persistent (set and forget), so every (re)load will be passed the same param/value for the lifetime of the store. Note that you can override extraParams at any time, prior to doing a (re)load of your store.



someStore.proxy.extraParams = {
someParam: 'someValue'
}

someStore.load();

mvosantos
23 Apr 2012, 9:43 AM
I needed to do this on a combobox, so there is what I did:

listeners: {
change: function(){
this.store.proxy.extraParams = {
entityType: 'cliente'
}
}
}

Is that the best to do?

friend
24 Apr 2012, 4:00 AM
That appears to be a good fit for your use case.