2010-12-20 8 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

는 다음과 같이 정의했다 :

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

탭이 변경 때 그냥 경고, 내 목적에 충분하다. 어떤 탭이 현재 탭인지 찾는 방법은 확실하지 않지만.

앞으로 도움이되기를 바랍니다.

+4

'Ext.TabPanel.getActiveTab()'는 활성 탭인 구성 요소를 반환합니다. – Mchl

+2

tabchange 이벤트 핸들러의 두 번째 매개 변수는 활성화 된 탭에 대한 참조입니다. – HOCA

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); 
     }); 
     }); 
     } 
    } 
     }