当前位置: 代码迷 >> JavaScript >> Extjs更替grid
  详细解决方案

Extjs更替grid

热度:129   发布时间:2012-11-10 10:48:50.0
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);
 
}
  相关解决方案