Activate the 2nd tab of the tab panel
16,075
Solution 1
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.tab.Panel-method-setActiveTab
There are also several examples of setting the active tab at the class level documentation.
Solution 2
Find the container of the tab panel. to get the container you can use Ext.getCmp
Ext.getCmp('center-region').setActiveTab('your-tab-name');
Author by
Sharon Watinsan
Updated on June 13, 2022Comments
-
Sharon Watinsan almost 2 years
I have a
tabpanel
, and a button on the 1st tab. When iclick
on thatbutton
, i need tosetfocus
to the 2nd tab andactivate
it (as in show content that belongs to that tab). My code is as follows, and i unable tosetFocus
oractivate
that tab from theButton 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 } });