hAcky
hAcky

Reputation: 37

How to reload grid by providing different url's to grid

I want to reload my grid on checking of different radio buttons,but with the new urls which i want to provide to grid to give different different columns inside grid..

this is my radio button where i want to give different url to my grid.

{
    boxLabel: ' 1', name: 'rb-horiz-3', inputValue: 1,
    listeners: {
    check: function(){ 
        //what i write here to 
        // reload grid with different url ....
    }}
}

this is my grid..

{
    xtype:'grid',
    store:new Ext.data.JsonStore({
        id:'store_id',
        root:'result',
        totalProperty:'total',
        fields:[
            {name:'rank'},
            {name:'pg'},
        ],
        baseParams:{start:0,limit:20},
        url:'pgrouting!getGridData.action',//this i want to change on checking of radio button...
            autoLoad:true,
            method:'POST'}

Upvotes: 2

Views: 230

Answers (1)

And-y
And-y

Reputation: 1524

As @MMT said in the comment, set the url of the bound proxy to an new url and then perform a load of the store.

check: function(){ 
    var url = http://example.com/data; // set the specific url
    // what you need here is a reference to your grid or store
    var store = grid.getStore();       // get the store from the grid
    var proxy = store.getProxy();      // get the proxy from the store
    proxy.setUrl(url);                 // change the url of the proxy
    store.load();                      // load the new data
}}

What you need in the check listener is a reference to either the grid or the store of the grid.

Upvotes: 1

Related Questions