PDA

View Full Version : mygrid.reconfigure(newstore) not working, wipes out data



xjscrafter
8 Jan 2014, 11:41 AM
I need to change a grid store on the fly and am using the gridpanel reconfigure() method.

It seems to be working, because the window is created, the old store data displays briefly, and then the new store data displays, but then the new data seems to be removed and the grid is empty.

Any ideas?


var importsLookup = Ext.create('com.myco.WizardLookupImports', {
closeable: true,
modal : true
}).show();

var selectDatastoresController = AMC.app.getController("com.myco.WizardLookupHostDatastoreController");

var sharedStorageStore = Ext.create('com.myco.WizardSelectedDataStore');

sharedStorageStore.loadData(selectDatastoresController.selectedDatastores);

importsLookup.down('gridpanel').reconfigure(sharedStorageStore);

scottmartin
8 Jan 2014, 1:03 PM
You should not need to call loadData. Also try adding the columns config:



Ext.onReady(function(){

var store = Ext.create('Ext.data.Store', {
fields : ['name', 'email', 'change'],
data : {'items' : [
{ 'name' : 'Lisa', 'email' : 'lisa@simpsons.com', 'change' : 100 },
{ 'name' : 'Bart', 'email' : 'bart@simpsons.com', 'change' : -20 },
{ 'name' : 'Homer', 'email' : 'home@simpsons.com', 'change' : 23 },
{ 'name' : 'Marge', 'email' : 'marge@simpsons.com', 'change' : -11 }
]},
proxy : {
type : 'memory',
reader : {
type : 'json',
root : 'items'
}
}
});

var columns = [
{ header : 'Name', dataIndex : 'name' },
{ header : 'Email', dataIndex : 'email', flex : 1 },
{ header : 'Change', dataIndex : 'change' }
];

var columnsNew = [
{ header : 'Name', dataIndex : 'name' },
{ header : 'Email', dataIndex : 'email', flex : 1 }
];

var grid = Ext.create('Ext.grid.Panel', {
title : 'Simpsons',
store : store,
columns : columns,
height : 200,
width : 400,
renderTo : Ext.getBody()
});

setTimeout(function(){
grid.reconfigure(store,columnsNew);
}, 2000);

setTimeout(function(){
grid.reconfigure(store,columns);
}, 4000);

});