PDA

View Full Version : ext4.x re-set (pre-existing) tab's title in tab panel



foobarr
23 Dec 2011, 8:02 AM
Spent about an 1.5 hours finding a solution...here is what finally works:

tabPanel.getTabBar().activeTab.setText("foobar");

Ext.tab.Panel activeTab property is a container, which provides no access to the tab button; likewise with the return value of Ext.tab.Panel.getActiveTab()

But Ext.tab.Bar activeTab property is an Ext.tab.Tab, which inherits from button, which provides a setText() method to change the button's text.

mitchellsimoens
23 Dec 2011, 10:13 AM
Just use the setTitle method on the tab item.


var tabpanel = Ext.create('Ext.tab.Panel', {
renderTo : Ext.getBody(),
width : 400,
height : 400,
items : [
{
title : 'One',
html : 'one'
},
{
title : 'One',
html : 'two'
}
]
});

var tabitem = tabpanel.getActiveTab();

tabitem.setTitle('One Changed');