PDA

View Full Version : Display picture of an active tab only in a tab panel



The_Mundane
10 Jun 2014, 7:01 AM
I have a tab panel with two tabs.
I wish that both tabs would contain images alongside their text, yet the image on each tab would be shown only when the tab is clicked (active), otherwise it won't be shown.
Can it be done?

Phil Guerrant
10 Jun 2014, 8:50 AM
Sure, you can listen for your tab panel's tabchange (http://docs.sencha.com/extjs/5.0.0/apidocs/#!/api/Ext.tab.Panel-event-tabchange) activate event and call one of the following methods to set/unset the icon

- setIcon()
- setIconCls()
- setGlyph()

for example:



onTabChange: function(tabPanel, newCard, oldCard) {
newCard.setIconCls('foo');
oldCard.setIconCls(null);
}

The_Mundane
12 Jun 2014, 3:38 AM
Thank you ! that worked.