2010-12-20 16 views
5

EXTJSのタブスイッチにOnClickイベントを添付する方法はありますか?EXTJS OnClick Tabイベント

私はこのようなグリッドを作る:

var simple = new Ext.FormPanel({ 
    labelWidth: '100%', 
    border:false, 
    width: '100%', 
      style: 
      { 
       height: '291px' 
      }, 
    items: { 
     xtype: 'tabpanel', 
     activeTab: 0, 
     //labelWidth: 75, // label settings here cascade unless overridden 
     items:[{ 
     url:'save-form.php', 
     title: 'Tab 1', 
    ... 

ありがとう!

答えて

7

タブは、次のように定義された後、私はリスナーに追加で私の目的には十分です。どのタブが現在のタブであるかを調べる方法はわかりません。

これは将来的に誰かに役立つことを願っています。

+4

'Ext.TabPanel.getActiveTab()'はアクティブなタブであるコンポーネントを返します。 – Mchl

+2

tabchangeイベントハンドラの2番目のパラメータは、アクティブ化されたタブへの参照になります。 – HOCA

2

火災時にアクティブなタブが変化していることtabchangeイベントがあります:これはちょうど、タブが変更されたときに警告

//define all tabs, and after the ] from the tab panel JSON: 
listeners: { 
    'tabchange': function(tabPanel, tab) { 
     alert("tab changed"); 
    } 
} 

http://www.sencha.com/learn/Ext_FAQ_TabPanel

0
There is no event for tab click in TabPanel, however you can bind into click event on each tab. You can add custom event. 
Following example help to you. 


{ 
    xtype : 'tabpanel', 
    items : [{ 
    xtype : 'panel', 
    title: 'ABC' 
    },{ 
     xtype : 'panel', 
     title : 'XYZ' 
}], 
    listeners: { 
    render: function() { 
    this.items.each(function(panel){ 
     // Added tabclick event for tabpanel                   
     panel.tab.on('click', function(){ 
     panel.addEvents('tabclick'); // addded event to panel 
     panel.fireEvent('tabclick', panel); 
     }); 
     }); 
     } 
    } 
     }