Extjs改变商店

时间:2011-07-17 13:21:16

标签: extjs store

我有一个data.store let的名字,它将store1绑定到图表中。我想从store1创建一个新商店(我想在store1上进行计算,比如求和一些记录)让我们说store2,然后将它绑定到图表。现在对store1的任何更改都会反映到图表中。

我也希望将它与store2保持一致。

我怎样才能实现这样的目标?

我是分机的新手,我要求更好地理解架构。

由于

3 个答案:

答案 0 :(得分:1)

为store1创建一个监听器,在加载后,它会填充本地数组存储(带有静态数据的ext示例)。例如,store1是json,第二个store2是完全派生的数据

答案 1 :(得分:0)

hpavc提示为真。请参阅example,其中“变换”的方法可以填充store2

答案 2 :(得分:0)

I realize this is an old question but wanted to document a little better for others who will find this answer in the future.

Caution when adding a load listener to a store. If using load listeners you have to be sure to include single: true so it will self dispose. If you do not dispose of the listener this becomes a "memory leak" in your program because each time a store is called another listener is going to be added increasing the number of items the load listener will trigger and increasing the amount of memory used.

A cleaner way to handle this is using a callback on the load event

store.getProxy().extraParams = {
WI: Ext.getCmp('transferManagerMain').MenuID,
UID: Ext.getCmp('transferManagerMain').UID,
companykey: obj.$widgetRecord.data.CompanyKey,
transferid: obj.$widgetRecord.data.TransferID
};
store.load({
    callback: function (records, operation, success) {
        var Tier2PayrollWdw = Ext.create('object');
        var responseJson = JSON.parse(operation.getResponse().responseText);
        var warnlinArr = responseJson.warnlines;
        Ext.fireEvent('setDataViewErrWarnLineArr', warnlinArr);
        Tier2PayrollWdw.setWidth(Ext.getBody().getViewSize().width - 300);
        Tier2PayrollWdw.setHeight(Ext.getBody().getViewSize().height - 300);
        Tier2PayrollWdw.setTitle('Data View - ' + 
    obj.$widgetRecord.get('OriginalFileName') + ' Transfer Date: ' + 
    Ext.util.Format.date(obj.$widgetRecord.get('TransferTime'), 'm/d/Y'));
    Tier2PayrollWdw.show();
    }
});

The callback does not continue to add listeners.