Bogus
Bogus

Reputation: 245

How to change store/url for grid in controller?

Is it possible to change url for Store which is assigned to grid? I do sth like that, but it looks very ugly. I am sure there is another way:

Ext.define('APP.controller.List', {
    extend : 'Ext.app.Controller',
    stores : ['Users', 'Reports'],
...
 // after click on some button
var lv = this.getUserlist();
lv.store.getProxy().api.read = 'data/reports.json'; // UGLY WAY to change url
lv.store.reload(); // and now my list has new content

In other way I have one list but I would like to load data there using 2 stores (users and reports). I know that store is assigned to list (grid) forever. 

How do it better without change url in store->proxy ?

Thanks for help.

Upvotes: 0

Views: 2384

Answers (1)

Alex Tokarev
Alex Tokarev

Reputation: 4861

Use Store.setProxy() method instead:

var lv = this.getUserList();

lv.store.setProxy({
    type: 'ajax',
    url:  'data/reports.json'
});

I would also recommend to rethink your design if it calls for one Grid with two Stores. Something's wrong here.

Upvotes: 2

Related Questions