Sab*_*eti 3 grid loops store extjs4
我想动态创建我的模型字段(在ExtJS 4中).例如,有时它是0到3,有时它是0到7.这些数据来自JSON文件(和存储).这是我的模特:
Ext.define('MyApp.model.User', {
extend: 'Ext.data.Model',
fields: ['0','1','2','3','4','5']
});
Run Code Online (Sandbox Code Playgroud)
我尝试了很多方法来手动获取模型并创建字段,但是当涉及网格时,我有空行数据而没有任何错误.例如,网格中有8个空行.
任何帮助,将不胜感激
我使用商店加载回调返回的记录动态生成我的模型.以下是我使用记录动态创建字段的方法.
roomTypesStore_Loaded: function (records) {
var roomType;
var fields = [
{ name: 'Id', type: 'int' },
{ name: 'Date', type: 'date' }
];
for (var i = 0; i < records.length; i++) {
roomType = records[i].data;
fields[2 + (3 * i) + 0] = { name: roomType.Name + 'Rates', type: 'string' };
fields[2 + (3 * i) + 1] = { name: roomType.Name + 'Selling', type: 'string' };
fields[2 + (3 * i) + 2] = { name: roomType.Name + 'Booked', type: 'string' };
}
var model = {
extend: 'Ext.data.Model',
fields: fields
};
Ext.define('HEB.store.Schedule', model);
var scheduleGrid = this.getScheduleGrid();
var scheduleStore = this.getScheduleStore();
if (scheduleGrid != null && scheduleStore != null) {
scheduleGrid.reconfigure(scheduleStore, columns);
}
},
Run Code Online (Sandbox Code Playgroud)