如何在控制器中更改网格的存储/网址?

时间:2012-08-06 14:22:54

标签: extjs store

是否可以更改分配给网格的商店的网址?我这样做,但看起来很难看。我相信还有另一种方式:

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.

1 个答案:

答案 0 :(得分:2)

改为使用Store.setProxy()方法:

var lv = this.getUserList();

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

如果它需要一个带有两个商店的网格,我还建议重新考虑你的设计。这里出了点问题。