Extjs 4将工具栏添加到面板dockeditems运行时

时间:2011-12-13 13:37:50

标签: extjs4 toolbar

我想在创建面板后创建一个dockedItem工具栏:

Ext.onReady(function() {
    Ext.create('Ext.container.Viewport', {
        layout: 'border',
        items: [{
            region: 'center',
            xtype: 'panel',
            listeners: {
                afterrender: function(panel) {
                    //Below gives: Uncaught TypeError: Object #<Object> has no method 'getItemId'
                    panel.dockedItems.add({
                        xtype: 'toolbar',
                        dock: 'bottom',
                        items: [{
                            text: 'adfsadf'
                        }]
                    });
                }
            }
        }, {
            region: 'west',
            title: 'west',
            html: 'west',
            width: 120
        }, {
            region: 'east',
            title: 'east',
            html: 'east',
            width: 120
        }, {
            region: 'north',
            html: 'north',
            title: 'north',
            height: 60
        }, {
            region: 'south',
            html: 'south',
            title: 'south',
            height: 60
        }]
    });
});

错误是:

Uncaught TypeError: Object #<Object> has no method 'getItemId'

关于如何做到这一点的任何想法?

1 个答案:

答案 0 :(得分:9)

没关系......比我想象的要简单。

解决方案:

panel.addDocked({ ... });