EXTJS 4 动态grid

时间:2014-05-09 18:09:47   收藏:0   阅读:484

var grid=Ext.getCmp("GridPanel1");
var store = grid.getStore();
Ext.Ajax.request({
url:"server/grid.json",
params:{},
success:function(response, option){

grid.setStore( Ext.JSON.decode(response.responseText) );

}
} );

自己下载json文件

 

setStore: function(msg) {
if (Ext.getCmp("GridPanel1") !== undefined) {
Ext.getCmp("GridPanel1").destroy();
}
if (Ext.getCmp("gridStore") !== undefined) {
Ext.getCmp("gridStore").remove();
}
var store = new Ext.data.JsonStore({
id: "gridStore",
data: msg.data,
fields: msg.fieldNames
});

//var cm = new Ext.grid.ColumnModel(msg.colName);
var grid = new Ext.grid.GridPanel({
id: "GridPanel1",
height: 240,
width: 750,
dock: ‘top‘,
region: ‘center‘,
autoScroll: true,
split: true,
border: false,
columns: msg.colName,
store: store

});
grid.render("FirstPanel");
}

 

赋值 data fields columns 

EXTJS 4 动态grid,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!