猿问

如何在 extJS 网格上动态加载小部件网格列

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

        }

    }]

});


哆啦的时光机
浏览 176回答 1
1回答

萧十郎

要将列动态添加到插件中,您必须在插件列数组中推送列配置。grid.getPlugin().config.widget.columns.push({     text      : 'Item',     dataIndex : 'item',     flex      : 1}, {     text      : 'Description',     dataIndex : 'desc',     flex      : 2});在这里为您创建了一个小提琴
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答