mercredi 2 juillet 2014

Session caching data even after store has been cleared and reloaded

This feels like a bug, but maybe there's a step I need to do before reloading a store that is causing this issue, but here's the scenario:

I have a ViewModel defined like so:



Code:



Ext.define('cc.view.main.MainModel', {
extend: 'Ext.app.ViewModel',


alias: 'viewmodel.main',


session: true,


stores: {
orders: {
model: 'Order',
session: true,
autoLoad: false
}
}
});

In my view, I have session also set to true. I have a simple grid defined that's bound to the store listed above. I have a button that loads the store with a set of extraParams. When you push a different button, it deletes the data in the store and loads the store with a different set of extraParams.

The issue is if a change was made in the data set between pressing button 1 versus pressing button 2, for example if I have a json value of button: 1 and as soon as you press button one, it changes that value on the server to button: 2, when I press button 2 and that data is reloaded with that changed value, the browser still sees it as being button: 1, even though the ajax call and response is very clearly showing it is indeed 2.


There's some sort of session caching problem, or I'm missing something when clearing the store.


The code flow goes like this:


Press button 1, data set loads into the grid, and a change is made on the server for one of the values on the record to switch from a value of 1, to a value of 2.


Press button 2, the data set is cleared from the store, and reloaded with the new data set, but the first record that used to have a value of 1, and now has it set as 2, still shows in the grid as it being 1 but the actual network/ajax call returned that it is in fact 2.


If I disable the session variables on the ViewModel/View.. things work fine.


I'm using this bit of code to clear the store data between loading data set 1 (button 1) and data set 2 (button 2)



Code:



clearStore: function(store) {
store.loadData([],false);
}

If I run the clearStore function manually, the grid empties out as expected, if I try to iterate or run an each on the store after I clear it, it returns no results, it is empty. So I would expect when I push button 2, that the new data loaded in would be loaded correctly, and it does load, but any record that was in data set 1, loads in how it was at the time it was initially loaded, in other words it doesn't accept that the data is different when it comes through as data set 2.

This is some unusual caching issue it seems, and it's in a memory space I can't seem to clear or get rid of so that when I load the data from data set 2 it reflects properly in the grid.


I have also tried attaching to the session and running a reject() and a clear on that to force it to purge any changes it thinks exists but that doesn't work either.


So... a bug maybe?





Aucun commentaire:

Enregistrer un commentaire