【问题标题】:How to load widget grid columns dynamically on extJS grid如何在 extJS 网格上动态加载小部件网格列
【发布时间】:2019-09-12 08:38:29
【问题描述】:

我有一个网格,当我展开行时,在那个网格中,还有另一组数据要显示。我希望那些网格列是动态的。根据我的 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.
        }
    }]
});

【问题讨论】:

    标签: javascript extjs extjs6


    【解决方案1】:

    要向插件动态添加列,您必须将列配置推送到插件列数组中。

    grid.getPlugin().config.widget.columns.push({
         text      : 'Item',
         dataIndex : 'item',
         flex      : 1
    }, {
         text      : 'Description',
         dataIndex : 'desc',
         flex      : 2
    });
    

    为你创造了一个小提琴here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-05
      • 2011-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-01
      相关资源
      最近更新 更多