【问题标题】:Add item to tabBar of a tabPanel in extjs在extjs中将项目添加到tabPanel的tabBar
【发布时间】:2014-09-27 19:45:26
【问题描述】:

我有一个无法修改的静态 tabPanel。它没有任何 tabBar 配置。但我想用其中一个子面板向它的 tabBar 添加一些项目(在 tabPanel 右侧添加一些按钮)。我怎样才能做到这一点?我正在使用 extjs 4.2。

我的标签栏:

tabBar: {
    items: [{
        xtype: 'tbfill'
    }, 
    {
        itemId : 'completeButton',
        iconCls : 'icon-complete',
        xtype: 'button',
        text: 'complete'
    }, {
        itemId : 'diagramButton',
        iconCls : 'icon-diagram',
        xtype: 'button',
        text: 'diagram'
    }]
}

将项目添加到 tabBar 的代码:

//childPanel is a direct child of rootTabPanel
//button is a button that should be added to rootTabPanel tabBar
addButton2Toolbar : function(childPanel,button){
    var rootTabPanel = childPanel.up('tabpanel');
    // add button to tabBar of rootTabPanel ?????
}

【问题讨论】:

    标签: javascript extjs extjs4.2


    【解决方案1】:

    我已将 fieldcontainer 项添加到 tabBar 并将 tabBars 项移动到 fieldcontainers 项。

    tabBar: {
        items: [{
            xtype: 'tbfill'
        }, {
            xtype : 'fieldcontainer',
            itemId : 'toolBar',
            layout : 'hbox',
            items : [ {
                itemId : 'completeButton',
                iconCls : 'icon-complete',
                xtype: 'button',
                text: 'complete'
            }, {
                itemId : 'diagramButton',
                iconCls : 'icon-diagram',
                xtype: 'button',
                text: 'diagram'
            }]
        }]
    }
    

    将项目添加到 tabBar 的代码:

    //childPanel is a direct child of rootTabPanel
    //button is a button that should be added to rootTabPanel tabBar
    addButton2Toolbar : function(childPanel,button){
        var rootTabPanel = childPanel.up('tabpanel');
        var toolBar = rootTabPanel.down('fieldcontainer#tabBar');
        toolBar.add(button);
    } 
    

    【讨论】:

    • 谢谢!我必须实现一些非常相似的东西,这是一个完美的解决方案!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-07
    • 2019-07-30
    • 1970-01-01
    • 1970-01-01
    • 2014-02-05
    相关资源
    最近更新 更多