javascriptextjsextjs6-classic

Binded store not reflecting values after adding record in store


I want to do some manipulations in the formula based on the store. When viewmodel loads that formula is getting triggered and do the manipulations properly but when I add a record in store its not getting triggered.

I have created a fiddle representing the above behavior. You can find it here. On click of button a new record gets added to the store. So formula should get triggered but its not whereas fields defined in the data object of viewmodel are working fine.

On googling I found that this binding should be deep copy. So I tried that as well but it dint resolved the issue.

formulas: {
   firstTestStoreRecord: {
     bind: {
        bindTo: '{testStore}',
        deep: true
     },
     get: function(testStore) {
        return testStore.getAt(0);
     }
   }
}

Any idea how can it be achieved?


Solution

  • Used datachanged event on the store as binding doesnt work with store data update.

    stores: {
      firstTestStoreRecord: {
        model: 'Common.model.firstTestRecord',
        autoLoad: false,
        listeners: {
          datachanged: () => {console.log('triggered')}
        }
    }