Dynamic 在extjs中创建动态网格
我需要在ExtJS中创建一个动态Dynamic 在extjs中创建动态网格,dynamic,extjs,grid,Dynamic,Extjs,Grid,我需要在ExtJS中创建一个动态gridpanel。为此,我使用了一个action列: handler: function(view, rowIndex, colIndex, item, e) { var tabs = Ext.getCmp('northPanel'); var rec = view.getStore().getAt(rowIndex); modelFactory(rec.get('Reference'), rec.get('ResultFields')
gridpanel
。为此,我使用了一个action列
:
handler: function(view, rowIndex, colIndex, item, e) {
var tabs = Ext.getCmp('northPanel');
var rec = view.getStore().getAt(rowIndex);
modelFactory(rec.get('Reference'), rec.get('ResultFields'));
console.log(rec.get('ResultFields'));
console.log('start adding tab');
tabs.add({
title: 'Report: ' + rec.get('Reference'),
closable: true,
dockedItems: [{
xtype: 'toolbar',
dock: 'top',
items: [{
xtype: 'tbfill'
}, {
xtype: 'button',
text: 'Export report'
}, {
xtype: 'button',
text: 'Refresh data'
}]
}],
xtype: 'tabpanel',
items: [{
xtype: 'gridpanel',
title: 'Gridview',
forceFit: true,
store: ND.store,
columns: []
}]
});
console.log('tab created');
},
现在我需要为这个网格创建列。我需要创建的列位于rec.get('ResultFields')
中。当我使用console.log()
时,我在firebug中看到:
[Object {
name = "currentSimAllocationByCcu", type = "textfield", format = null
}, Object {
name = "wanNumber", type = "textfield", format = null
}, Object {
name = "carrierName", type = "textfield", format = null
}, Object {
name = "dataPackageName", type = "textfield", format = null
}, Object {
name = "simIccid", type = "textfield", format = null
}, Object {
name = "expiryTime", type = "textfield", format = null
}, Object {
name = "bytesRx", type = "textfield", format = null
}, Object {
name = "bytesTx", type = "textfield", format = null
}]
如何使用此创建列 有什么问题吗 若在创建网格之前获得了关于列的信息,那个么就根据字段的数组创建一个或多个列。大概是这样的:
var _cols = [],
_flds = rec.get('ResultFields');
Ext.Array.each(_flds, function(f) {
_cols.push(Ext.create('Ext.grid.column.Column', {
text: f.get('name'),
dataIndex: f.get('name')
}));
});
然后在创建网格时使用该
\u cols
。什么问题
若在创建网格之前获得了关于列的信息,那个么就根据字段的数组创建一个或多个列。大概是这样的:
var _cols = [],
_flds = rec.get('ResultFields');
Ext.Array.each(_flds, function(f) {
_cols.push(Ext.create('Ext.grid.column.Column', {
text: f.get('name'),
dataIndex: f.get('name')
}));
});
然后在创建网格时使用该\u cols