1
votes

I have a data.store let's name it store1 bind in a chart. I want to make a new store from store1(I want to make calculations on store1 such as sum some records) let's say store2 and then bind this to the chart.Until now any changes to store1 reflect to the chart.

I want to keep this with store2 also.

How can I achieve something like that?

I'm a newbie in ext and I'm asking for better understanding of the architecture.

Thanks

3

3 Answers

1
votes

Make a listener for store1, that after it loads it populates a local array store (the ext examples with static data). Only store1 is json for example, the second store2 one is completely derived data

0
votes

hpavc prompted true. See an example where the method of "transforms" can be filled store2

0
votes

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.