2011-09-02 83 views
0

我有一個現有的工具欄,並希望爲其添加選項卡,以便在使用卡布局的兩個面板之間進行切換。什麼是我最好的選擇,是否有任何這樣做的例子?將選項卡添加到ExtJS中的現有工具欄

  • 是否可以將標籤添加到我現有的工具欄?更改我現有按鈕上的xtype並不能提供我希望看到的選項卡。
  • 創建一個包含我的兩張卡片的選項卡面板,將每個選項卡映射到其面板。有了這個選項,我可以添加額外的按鈕和菜單到標籤面板嗎?

下面是我現有的工具欄代碼的一個示例,message_button和attachments_button只是簡單地有一個tab類型,然後以某種方式模擬選項卡功能?

Ext.define('MyArchive.Toolbar', {                                     
    alias: 'myarchive.toolbar',                                      
    extend: 'Ext.toolbar.Toolbar',                                     
    dock: 'top',                                          
    width: '100%',                                         
    items: [ 
    // Pretty straight forward buttons with a listener, nothing fancy 
    messages_button,                                         
    attachments_button,                                   
    '->',                                           
    { xtype: 'button', id: 'forward-button', text: 'Forward' },                              
    '-',                                           
    { xtype: 'button', id: 'recover-button', text: 'Recover' },                              
    '-',                                           
    {                                            
    text: 'Download',                                        
    menu: {                                          
     xtype: 'menu',                                        
     id: 'download-menu',                                      
     items: [                                         
     {xtype: 'menuitem', id: 'download-original', text: 'Original', iconCls: 'download-icon'},                     
     {xtype: 'menuitem', id: 'download-pdf', text: 'PDF', iconCls: 'pdf-icon'}                         
     ]                                           
    }                                            
    }                                            
    ] 

回答

0

是否有可能的選項卡添加到現有的工具欄?在我現有的按鈕上更改 xtype沒有爲我提供希望看到的選項卡 。

我試過了。但沒有運氣。

創建一個包含我的兩張卡的標籤面板,將每個標籤 映射到其面板。使用此選項,我可以將其他按鈕和菜單 添加到選項卡面板嗎?

這是可能的。但結果看起來很醜(你可以用CSS來裝飾它)。
使用tabpanel.tabBar.add()添加按鈕和菜單(Here is demo):

tabpanel.tabBar.add({ 
    xtype: 'button', 
    text: 'hallo, I\'m a button' 
}); 
tabpanel.tabBar.add({ 
    xtype: 'splitbutton', 
    text: 'Download', 
    menu: { 
     xtype: 'menu', 
     id: 'download-menu', 
     // ans so on ...