Fabien
Fabien

Reputation: 787

extjs: nested baseParams in request

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

Answers (3)

Mike Tallroth
Mike Tallroth

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

Amit Sharma
Amit Sharma

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

Igor Pavelek
Igor Pavelek

Reputation: 1444

Or use something like this (which is better than a long url string):

baseParams: {
  'foo[controller]': 'demo',
  'foo[action]': 'index'
}

Upvotes: 3

Related Questions