2012-07-16 66 views
2

我有一個tabpanel,並在第一個標籤上有一個按鈕。當我clickbutton,我需要setfocus第二個標籤和activate它(如在顯示內容屬於該標籤)。我的代碼如下,我無法setFocusactivate該選項卡從Button click event激活標籤面板的第二個標籤

Ext.define('MyApp.view.MyTabPanel', { 
    extend: 'Ext.tab.Panel', 

    height: 250, 
    width: 400, 
    activeTab: 0, 

    initComponent: function() { 
     var me = this; 

     Ext.applyIf(me, { 
      items: [{ 
       xtype: 'panel', 
       title: 'Tab 1', 
       items: [{ 
        xtype: 'button', 
        text: 'MyButton', 
        listeners: { 
         click: { 
          fn: me.onButtonClick, 
          scope: me 
         } 
        } 
       }] 
      }, { 
       xtype: 'panel', 
       title: 'Tab 2' 
      }, { 
       xtype: 'panel', 
       title: 'Tab 3' 
      }] 
     }); 

     me.callParent(arguments); 
    }, 

    onButtonClick: function (button, e, options) { 
     // Set Focus, and activate the 2nd tab 
    } 

}); 

回答

4

找到標籤面板的容器。獲取可以使用的容器Ext.getCmp

Ext.getCmp('center-region').setActiveTab('your-tab-name'); 
+0

謝謝,這很有幫助 – 2012-07-16 07:18:12