在ExtJS4.1.1中,如何以编程方式向按钮组添加项

在ExtJS4.1.1中,如何以编程方式向按钮组添加项,extjs,extjs4,items,buttongroup,Extjs,Extjs4,Items,Buttongroup,在ExtJS4.1.1中,如何以编程方式向按钮组添加项?如果我在定义buttongroup时添加项目,它会起作用,例如: Ext.define('company.ButtonGroup', { extend: 'Ext.container.ButtonGroup', title: 'File', columns: 2, defaults: { scale: 'small' }, items: [ { text

在ExtJS4.1.1中,如何以编程方式向按钮组添加项?如果我在定义buttongroup时添加项目,它会起作用,例如:

Ext.define('company.ButtonGroup', {
    extend: 'Ext.container.ButtonGroup',
    title: 'File',
    columns: 2,
    defaults: {
        scale: 'small'
    },
    items: [
            { text: 'New', iconCls: 'new16' },
            { text: 'Open', iconCls: 'open16' }
            ]
});
var fileButtongroup = Ext.create('company.ButtonGroup');
但是,如果我尝试分配一个项目数组,它将不起作用。例如:

var fileArr = [
            { text: 'New', iconCls: 'new16' },
            { text: 'Open', iconCls: 'open16' }
            ];
Ext.define('company.ButtonGroup', {
    extend: 'Ext.container.ButtonGroup',
    title: 'File',
    columns: 2,
    defaults: {
        scale: 'small'
    }
});
var fileButtongroup = Ext.create('company.ButtonGroup');
fileButtongroup.items = fileArr;

此外,我也没有看到任何
setItems()
方法。

因为
items
数组在组件初始化时(在initComponent()中)会得到处理

如果要在创建按钮组后将其添加到按钮组中,则应使用以下方法。顺便说一下,它适用于任何类