2014-09-27 50 views
1

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

我的TabBar:

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 ????? 
} 

回答

2

心中已经加入了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); 
} 
+0

感谢这个!我不得不实施非常相似的东西,这是一个完美的解决方案! – InsaneOstrich 2015-01-30 00:21:27