首页 > 解决方案 > 如何在 ExtJs 的标签栏中动态添加 tbar

问题描述

我需要在 tabpanel 的第二个选项卡中动态添加 tbar(不想在 tbar 中动态添加项目,但需要根据某些条件添加 tbar,否则应该添加 bot),下面是我的代码:

var wind = Ext.create("Ext.Window", {
                        modal: true,
                        scrollable: true,
                        items: [
                            {
                                margin: '0 0 0 10',
                                xtype: 'tabpanel',
                                reference: "MainTab",
                                plain: true,
                                resizeTabs: true,
                                flex: 1,
                                border: 3,
                                items: [
                                    {
                                        title: "Messages",
                                        rootTab: true,
                                        items: [{
                                           // item
                                        }] }, {    
                                        title: "Alarms",
                                        items: [{
                                                 //item,
                                        }],
                                        tbar: // need to add this tbar dynamically
                                        }] 

我已经尝试使用 dockedItems 使用 initComponent 但对我不起作用。

标签: extjsextjs7

解决方案


下面的小提琴使用的是现代的,但在经典中应该是相似的。它只是调用控制器上的 init 函数。

这是一个小提琴

小提琴的编辑器版本


推荐阅读