日期:2014-05-16  浏览次数:20295 次

Extjs更换grid

很基础的东西,在运行的时候更换grid的内容(grid结构,store的记录等)

?

?

//延时5秒
(function(){
		alert("pop out defer 5 seconds");
		changeGrid(grid);
}).defer(5000);

var changeGrid = function(grid){
	var index = new Ext.grid.RowNumberer();
      var newColumnModel = new Ext.grid.ColumnModel([index, {  
                header : "test once",  
                width : 230,  
                dataIndex : "test1",  
                sortable : true  
            }, {  
                header : "lalal twice",  
                width : 230,  
                dataIndex : "test2",  
                sortable : true  
            }]);
	var newStore = new Ext.data.ArrayStore({
        fields: [
           {name: 'test1'},
           {name: 'test2'}
        ]
    	});

   	// manually load local data
newStore.loadData([['魏超','哈哈哈'],['啊','这是测试啊'],['fasf ','唉,无聊的测试']]);
        //重新加载store和columnModel
	grid.reconfigure(newStore,newColumnModel);
	//grid.getTopToolbar().bind(newStore);
 
}