Reputation: 787
In the frame of an Ajax request, I am trying to use a nested object for parameter "baseParams". Basically, I would like to produce an URL like "ajax.php?foo[controller]=demo&foo[action]=index".
Bellow is the code that wrongly produces: "ajax.php?foo=[object]&foo=[object]".
Ext.data.JsonStore( baseParams: { foo: { controller: 'demo', action: 'index' } }, proxy: new Ext.data.HttpProxy({ method: 'GET', url: '/ajax.php' }), (...) );
Of course, I could write something like bellow but I was looking for a more nifty solution.
Ext.data.JsonStore( proxy: new Ext.data.HttpProxy({ method: 'GET', url: '/ajax.php?foo[controller]=demo&foo[action]=index' }), (...) );
After few attempts, I wonder if it is really possible. But maybe I missed something. Can you help?
Upvotes: 1
Views: 1854
Reputation: 11
I did something like this, which is identical in the end to Igor Pavelek's response, only a little more programmatic:
var foo = {
'controller' : 'demo',
'action' : 'index'
};
var gfObj = new Ext.ux.grid.GridFilters({paramPrefix: 'foo'});
var bp = gfObj.buildQuery(foo);
Ext.data.JsonStore({
baseParams : bp,
(...)
});
Upvotes: 1
Reputation: 1988
baseParams: {
foo['controller']: 'demo',
foo['action']: 'index'
}
I would recommend this , i think there is simple difference of commas from above
Upvotes: 0
Reputation: 1444
Or use something like this (which is better than a long url string):
baseParams: {
'foo[controller]': 'demo',
'foo[action]': 'index'
}
Upvotes: 3