PDA

View Full Version : Fully ajax-configurable GridPanel



nikochan
3 Jun 2010, 9:01 PM
I do this
component that extends gridpanel for replicate the behavior of viewConfig with storeConfig (assuming a default JsonStore config...), RowSelectionConfig and bbarConfig (tbar instead already implements this feature :-? ...)

So now, I can define a complete grid from the server-side and load it with a simple ajax request.



Ext.namespace('Ext.ux.grid.GridPanel');
Ext.ux.grid.GridPanel = Ext.extend(Ext.grid.GridPanel, {
initComponent : function(){
if(this.storeConfig != null){
this.store = new Ext.data.JsonStore(this.storeConfig);
}
if(this.RowSelectionConfig != null){
this.selModel = new Ext.grid.RowSelectionModel(this.RowSelectionConfig);
}
if(this.bbarConfig != null){
this.bbarConfig.store = this.store;
this.bbar = new Ext.PagingToolbar(this.bbarConfig);
}
Ext.ux.grid.GridPanel.superclass.initComponent.call(this);
}
});
Ext.reg('uxgrid', Ext.ux.grid.GridPanel);

/****************** example **********************/

Ext.Ajax.request({
url: jsBaseUrl + '/ajax/layouts_ext-list',
success: function ( result, request ) {
grid_model = Ext.util.JSON.decode(result.responseText);
this.grid = new Ext.ux.grid.GridPanel(grid_model);
}
}