PDA

View Full Version : Subsequent jsonStore load fails



shpula
4 Aug 2010, 12:08 AM
I have a situation where I need an entire gridPanel redrawed. There are changes in column model and the data, so I figured the easiest thing to do would be to delete the old one and draw a completely new one.

gridPanelInstance.remove(Ext.getCmp('myGrid')) // myGrid is a child of gridPanelInstance
grid = new Ext.grid.GridPanel({
id : 'myGrid',
title : 'myGrid title',
autoHeight : true,
width : columnModel.getTotalWidth(false), // don't include hidden fields
store : gridDataStore,
colModel : columnModel,
selModel : selModel,
loadMask : true
});
gridPanelInstance.add(grid);
gridPanelInstance.doLayout();
I do that in a callback function of my data store, like this:


gridDataStore.load({
params : {
...
},
callback : function(data, options, success) {
gridPanelInstance.remove(Ext.getCmp('myGrid'))
var grid = new Ext.grid.GridPanel({
store : gridDataStore, // all properties are same as above
...
});
// add and doLayout
}
});
It works just on the first load. In subsequent loads the gridDataStore's data property is null, and all I get is an empty grid. I also tried with load/reload (after the first load) functions but it doesn't help.

The data is correctly loaded from a store, data callback parameter is like it should be.

What am I missing?

Condor
4 Aug 2010, 12:12 AM
No, you don't need to replace the entire grid.

How about this method (http://www.sencha.com/forum/showthread.php?76406-jsonStore-gt-panel.items&p=371353#post371353)?

shpula
4 Aug 2010, 3:08 AM
The store from wich I was reading the data had autoDestroy property to true, and the gridPanel was the only one who was using it so it got destroyed right with the gridPanel. Setting the autoDestroy property to false solved the problem.