I have an ExtJS store like so:
var dataStore = new Ext.data.JsonStore({...});
I'm using it with a factory to get a GridPanel:
function CreateGrid(config) {
return new Ext.grid.GridPanel({
store: dataStore,
...
})
};
Now, when I run this code:
new Ext.Window({
closable: true,
items: CreateGrid(),
}).show();
The first time I run it, the grid works fine. However, if I close the window and re-open another one, I can't sort the columns anymore, nor refresh the store.
I've pinpointed the issue down to the store, and whatever is happening to it when the grid is destroyed. If I change my CreateGrid()
function to this instead:
function CreateGrid(config) {
return new Ext.grid.GridPanel({
store: new Ext.data.JsonStore({...}),
...
}
};
It works perfectly fine, except I'm getting a new store each time instead of re-using the old one.
How do I fix this problem so that I can destroy the grid without messing up the store? The thought behind this is that I want to keep the store around in order to preserve the column sorting and filtering, but destroy the grid in order to save on memory.