Ext.override(Ext.data.Store,{ addField: function(field){ if(typeof field == 'string'){ field = {name: field}; } this.recordType.prototype.fields.replace(field); if(typeof field.defaultValue != 'undefined'){ this.each(function(r){ if(typeof r.data[field.name] == 'undefined'){ r.data[field.name] = field.defaultValue; } }); } }, removeField: function(name){ this.recordType.prototype.fields.removeKey(name); this.each(function(r){ delete r.data[name]; }); } }); Ext.override(Ext.grid.ColumnModel,{ addColumn: function(column, colIndex){ if(typeof column == 'string'){ column = {header: column, dataIndex: column}; } var config = this.config; this.config = []; if(typeof colIndex == 'number'){ config.splice(colIndex, 0, column); }else{ colIndex = config.push(column); } this.setConfig(config); return colIndex; }, removeColumn: function(colIndex){ var config = this.config; this.config = [config[colIndex]]; config.remove(colIndex); this.setConfig(config); } }); Ext.override(Ext.grid.GridPanel,{ addColumn: function(field, column, colIndex){ if(!column){ if(field.dataIndex){ column = field; field = field.dataIndex; } else{ column = field.name || field; } } this.store.addField(field); this.colModel.addColumn(column, colIndex); }, removeColumn: function(name, colIndex){ this.store.removeField(name); if(typeof colIndex != 'number'){ colIndex = this.colModel.findColumnIndex(name); } if(colIndex >= 0){ this.colModel.removeColumn(colIndex); } } }); Ext.override(Ext.data.Store,{ addField: function(field){ if(typeof field == 'string'){ field = {name: field}; } this.recordType.prototype.fields.replace(field); if(typeof field.defaultValue != 'undefined'){ this.each(function(r){ if(typeof r.data[field.name] == 'undefined'){ r.data[field.name] = field.defaultValue; } }); } }, removeField: function(name){ this.recordType.prototype.fields.removeKey(name); this.each(function(r){ delete r.data[name]; }); } }); Ext.override(Ext.grid.ColumnModel,{ addColumn: function(column, colIndex){ if(typeof column == 'string'){ column = {header: column, dataIndex: column}; } var config = this.config; this.config = []; if(typeof colIndex == 'number'){ config.splice(colIndex, 0, column); }else{ colIndex = config.push(column); } this.setConfig(config); return colIndex; }, removeColumn: function(colIndex){ var config = this.config; this.config = [config[colIndex]]; config.remove(colIndex); this.setConfig(config); } }); Ext.override(Ext.grid.GridPanel,{ addColumn: function(field, column, colIndex){ if(!column){ if(field.dataIndex){ column = field; field = field.dataIndex; } else{ column = field.name || field; } } this.store.addField(field); this.colModel.addColumn(column, colIndex); }, removeColumn: function(name, colIndex){ this.store.removeField(name); if(typeof colIndex != 'number'){ colIndex = this.colModel.findColumnIndex(name); } if(colIndex >= 0){ this.colModel.removeColumn(colIndex); } } }); ------------------------------------------------------------------- 使用方法:Java代码 var grid = new Ext.grid.GridPanel({ store: new Ext.data.SimpleStore({ fields: ['A', 'B'], data: [['ABC', 'DEF'], ['GHI', 'JKL']] }), columns: [ {header: 'A', dataIndex: 'A'}, {header: 'B', dataIndex: 'B'} ] }); new Ext.Viewport({ layout: 'fit', items: grid }); grid.addColumn('C'); grid.addColumn({name: 'D', defaultValue: 'D'}, {header: 'D', dataIndex: 'D'}); grid.removeColumn('B'); ------------------------------------------------------------------- grid.addColumn('C'); //添加C列,空数据 grid.addColumn({name: 'D', defaultValue: 'D'}, {header: 'D', dataIndex: 'D'});//添加D列,有D数据 grid.removeColumn('B');//把之前的B列删除 一开始的时候columns配置一个空的,gridPane({columns:[{}]})然后调用这个方法gridPanel.reconfigure(gridPanel.store, Ext.grid.ColumnModel colModel ) ;后面这个是你动态组装出来的ColumnModel这就OK了