PDA

View Full Version : reconfigure gridpanel issues



alupuli
23 Feb 2010, 1:38 PM
got a gridpanel in UI and needs to reconfigure it (for eg. on click of button outside.)




Ext.onReady(function () {
var MyGrid = new Ext.grid.GridPanel({
id: 'MyGrid',
.......
});
}


Issue 1.
reconfigure is in another function. so doing
Ext.get('MyGrid').reconfigure(myStore,cm); throws "Object doesn't support this property or method" error.

so I made var MyGrid global.

Issue 2.



var MyGrid = null;
Ext.onReady(function () {
MyGrid = new Ext.grid.GridPanel({
id: 'MyGrid',
.......
});
}
function reconfigure(xmldata_as_string) {
var cm = new Ext.grid.ColumnModel([{
id: 'title',
header: "<b><u>My Sites</u></b>",
sortable: false,
dataIndex: 'title'
}])
var myXmlReader = new Ext.data.XmlReader({
record: 'I',
id: '@E'
},
[{
name: 'title',
mapping: '@Title'
}]);
var myStore = new Ext.data.Store({
reader: myXmlReader
});
myStore.loadData(xmldata_as_string); //valid xml data as string returned from an xmlhttp call.
}

grid redraws to blank,
is this the right sample of reconfiguring gridpanel.
anything missing?

lleslie84
23 Feb 2010, 1:58 PM
HI alupuli (http://www.extjs.com/forum/member.php?u=91037): try Ext.getCmp('MyGrid').reconfigure(myStore,cm)

Ext.get() returns the element 'el'

Ext.getCmp() returns the grid object


have fun