2012-04-13 107 views
4

我有一個帶有兩個選項卡和頂部的工具欄的選項卡面板,該選項卡上有兩個按鈕,用於在選項卡內容上實現某些功能(按鈕對兩個選項卡都是通用的)。有沒有辦法將這些按鈕放在與選項卡相同的面板/ div中,即選項卡的最右側,以便在ui上節省一些空間? http://i.imgur.com/Flfpj.png在tabpanel中合併工具欄ExtJs 4

title: 'Results', 
layout: { type: 'fit', align: 'stretch' }, 
dockedItems: [{ 
    xtype: 'toolbar', 
    dock: 'top', 
    items: [{ 
       xtype: 'tbfill' // fills left side of tbar and pushes following items to be aligned to right 
      }, 
      { 
       xtype: 'label', 
       text: 'Export to: ' 
      }, 
      { 
       xtype: 'button', 
       text: 'Excel', 
       iconCls: 'icon-excel' 
      }, 
      { 
       xtype:'button', 
       text:'PDF', 
       iconCls:'icon-pdf' 
      }], 
    style: { padding: '8px' } 
}], 
items: 
    [{ 
    xtype: 'tabpanel', 
    id: 'results-tabpanel', 
    activeTab: 0, 
    border: false, 
    items: [{ 
     title: 'Results', 
     id: 'result-tab', 
     layout: { type: 'fit', align: 'stretch' }, 
     html: "Run a query to see results" 
    }, 
     { 
      title: 'Transactions', 
      id: 'transactions-tab', 
      layout: { type: 'fit', align: 'stretch' }, 
      html: "Run a query to see transactions" 
     }] 
}] 

回答

4

試試這個:

var tabPanel = Ext.getCmp("results-tabpanel"); 
tabPanel.tabBar.addTool([ 
    {xtype: "tbfill"}, 
    { 
     xtype: "label", 
     text: "Export to: " 
    }, 
    { 
     xtype: "button", 
     text: "Excel", 
     iconCls: "icon-excel" 
    }, 
    { 
     xtype: "button", 
     text: "PDF", 
     iconCls: "icon-pdf" 
    } 
]); 
+0

有沒有一種方法來設置填充這個,因爲按鈕都溢滿了一下? – Armaan 2012-04-13 19:43:25

+1

每個組件都有一個可以使用的'padding'配置,或者您可以對它們進行設計。另外,一個'Ext.toolbar.Toolbar'配置對象有一個名爲'enableOverflow'的配置,如果空間不足,會將額外的工具欄項目推送到側面的菜單中。 – Eric 2012-04-13 20:19:59

+0

也許只是改變按鈕的高度會更好。 – 2013-04-06 11:38:27