即时尝试构建动态网格,可以从
创建商店var data = JSON.parse(response.responseText),
columns = data.columns;
var store = Ext.create('Ext.data.Store', {
data: data
})
因为我想重新配置我在window.js中显示的网格
grid.reconfigure({
columns: columns,
store : store
});
答案 0 :(得分:2)
这是%100动态网格:小提琴:https://fiddle.sencha.com/#fiddle/trn
Ext.Ajax.request({
url: 'users',
success: function(response) {
var resp = Ext.JSON.decode(response.responseText).records;
var columnKeys = Object.keys(resp[0]);
var store1 = Ext.create('Ext.data.Store', {
fields: columnKeys,
data : resp
});
var columnObjects = []
Ext.each(columnKeys, function(key) {
columnObjects.push({
text: key,
dataIndex: key
});
});
var grid = Ext.create('Ext.grid.Panel', {
columns: columnObjects,
store: store1,
renderTo: Ext.getBody()
});
}
});