Hy,
I'm building an extension for gridpanel that retrieves column config and store config from server.
I've managed to get a working version of the extension but this version is not compatible with grid plugins, etc.
This is the "working version":
HTML Code:
/*global Ext, Easy*/
Ext.ns('Easy.Grid');
Easy.Grid = Ext.extend(Ext.grid.GridPanel, {
initComponent: function() {
this.store = new Ext.data.ArrayStore({
fields: ['wait']
});
this.tbar = this.tbar || [];
this.bbar = [];
this.store.loadData([['reading configuration...']]);
this.columns = [{width: 300, dataIndex: 'wait'}];
Easy.Grid.superclass.initComponent.apply(this, arguments);
this.config = {
url: this.gridConfig.loadUrl,
params: {
config: Ext.util.JSON.encode(this.gridConfig)
}
};
Ext.Ajax.request(Ext.apply(this.config, {
success: this.createGrid,
scope: this
}));
}, // eo function initComponent
createGrid: function(response){
var oCfg = Ext.decode(response.responseText);
this.oCfg = oCfg ;
//console.log(oCfg);
oNewStore = new Ext.data.Store({
remoteSort: true,
sortInfo: {field: oCfg.store.idProperty, direction:'ASC'},
baseParams:{
config: Ext.util.JSON.encode(this.gridConfig)
},
proxy: new Ext.data.HttpProxy({
method: 'POST',
url: this.gridConfig.dataUrl
}),
reader: new Ext.data.JsonReader(oCfg.store)
});
this.reconfigure(oNewStore, new Ext.grid.ColumnModel(oCfg.columns));
this.store.load({
params: {
start: 0,
limit: 500
}
});
this.doLayout();
},
// {{{
onRender: function() {
// call parent
Easy.Grid.superclass.onRender.apply(this, arguments);
} // eo function onRender
// }}}
});
Ext.reg('easyGrid', Easy.Grid);
However, even if this script is working it's not what I need, becose I need full compatibility with other grid plugins.
Is there a way to make the InitComponent wait for my ajax call to finish, so I don't have to declare dummy store and cm ... and breake others plugins?
Thanks