Hello Guys我用一个动态模型来刺激我需要一个循环来创建列,我发现这个“items.push({”但我不知道如何使用它。 请有人帮帮我。
onSqlChange: function (gridPanel, value) {
var me = this;
Ext.Ajax.request({
url: '{url action=getSqlDetails}',
params: {
fileName: value
},
success: function (response) {
var text = JSON.parse(response.responseText);
console.log(text);
me.mainWindow.grid.show();
var columns = [];
Ext.create('Ext.data.Model', {
items: columns
});
}
});
}
这是从JSON.parse(response.responseText);
答案 0 :(得分:3)
您的model
没有财产items
。您的grid
确实有store
,store
有model
且model
有fields
。您的grid
已columns
。
使用您使用ajax调用检索的列尝试reconfigure您的网格:
onSqlChange: function (gridPanel, value) {
var me = this;
Ext.Ajax.request({
url: '{url action=getSqlDetails}',
params: {
fileName: value
},
success: function (response) {
var text = JSON.parse(response.responseText),
grid = me.mainWindow.grid,
columns = text.columns;
grid.reconfigure(columns);
grid.show();
}
});
}
但是,它可以做得更清洁。可以在metachange
事件中动态设置列和字段。当您收听此消息时,您可以从该位置使用商店和列重新配置网格。在onSqlChange
中,您只需再次加载商店(这将导致触发metachange
并重新配置您的网格。)