View Full Version : Store: How to set parameters for its load action AFTER instantiation?

4 Oct 2011, 5:04 AM
Hi guys,

I need to set parameters on the request on the "beforeload" event of the store. Basically, I need to add to the URL that it uses to request, for example, a parameter "solr", so it could end up like this: myhost.com/find?solr=1. And use the "beforeload" event to change this value based on some logic.

In ExtJS 3 I could change them directly on the store, but now I don't know how. I've been looking for a way on the API, on the Ext.data.Operation class and others, without luck.

Is there a way to do this now?


4 Oct 2011, 5:11 AM
beforeload:function(store, operation) {
operation.params.solr = 1;

Does that work?

4 Oct 2011, 5:48 AM
Thanks! it works indeed. The only thing I've noticed is that I had to define the property "params" first, because it doesn't exist on the Ext.data.Operation object I receive in the beforeload event. I clarify this in case anyone is having the same problem.

Again, thanks a lot for your help!

4 Oct 2011, 5:57 AM
To clarify what I mean before:

onStoreBeforeLoad: function(store, operation, eventOptions) {
var searchField = this.down('mysearchtextfield');

operation.params = {
q: searchField.getValue()

Hope it helps if anyone is looking for this.