我有一个网格,在该网格中,当我展开行时,会显示另一组数据。我希望这些网格列是动态的。根据我的 json 数据,我想将数据推送到列中。但是在这里当我给出方法时,调试器不会去那里。谁能解释一下如何在 extJS 小部件列中加载动态列。
这是我的代码
Ext.define('myApp.view.base.grid.Window', {
extend: 'Ext.window.Window',
alias: 'widget.win',
title: 'my window',
height: 500,
width: 800,
layout: 'fit',
items: [{
xtype: 'grid',
columns: [{
text: 'Col 1',
dataIndex: 'col1',
flex: 1,
},{
text: 'col2',
dataIndex: 'col2',
flex: 1
}],
}],
plugins: [{
ptype: 'rowwidget',
widget: {
xtype: 'grid',
columns:[]//this.createColumn() // This columns i want to load dynamically.
}
}]
});
最佳答案
要将列动态添加到插件,您必须将列配置推送到插件列数组中。
grid.getPlugin().config.widget.columns.push({
text : 'Item',
dataIndex : 'item',
flex : 1
}, {
text : 'Description',
dataIndex : 'desc',
flex : 2
});
为您创建了一个 fiddle here
关于javascript - 如何在 extJS 网格上动态加载小部件网格列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57902884/