EXTJS 4 动态grid
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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。