View Full Version : Dynamically set params for ajax store?

20 Dec 2010, 6:47 AM
How do you do this in sencha touch? store.proxy.setUrl and store.setBaseParam aren't options.
I tried the extraParams property, but couldn't get it to do anything.
If I place parms in the url string, the string is built too early and the parms are empty.
If I put the url string in a variable I get the url was not provided error.

20 Dec 2010, 7:45 AM
The following code is working for me :

store.proxy.extraParams = {month:12, year:2010};

20 Dec 2010, 7:47 AM
I don't use autoLoad: true so I don't put the params on the store config. I usually set the params in reload function that is called upon component init...that way you can reuse when needed rather than statically define them on the store.

reload: function (p) {

url: '../dir/getData',
params: {
foo: 'bar',
p2: Ext.getCmp('someField').getValue(),
p3: this.someCustomPropertyISetOnComponent,
p4: p, //<-- passed into reload function

20 Dec 2010, 8:09 AM
Thanks Ezor. That format worked. Getting data back now and just have to figure out why I'm getting a unable to parse json string error.
Found that error in another thread. had to put data in quotes. {"data": [{...