PDA

View Full Version : Cannot programmatically select Tab after adding it to tab panel



iamcootis
6 Jun 2013, 11:13 AM
I've tried it several ways, but it never works



onAddNewTab: function(){
var newTab = Ext.create('App.view.tools.CommunicationTab', {
title: 'Communication ' + this.getCount()
});
var tab= this.getTabPanel().insert(this.getTabPanel().items.length -1, newTab);
this.setCount(this.getCount() + 1);

this.getTabPanel().setActiveTab(tab);

},


I've also tried: this.getTabPanel().setActiveTab(newTab); and every other config I could think of.

friend
7 Jun 2013, 3:47 AM
Try this:



onAddNewTab: function(){
var newTab = Ext.create('App.view.tools.CommunicationTab', {
title: 'Communication ' + this.getCount()
});
this.getTabPanel().add(newTab);
this.setCount(this.getCount() + 1);
this.getTabPanel().setActiveTab(newTab);
},

iamcootis
7 Jun 2013, 8:44 AM
I cannot use

this.getTabPanel().add(newTab);

because I'm inserting the panel in front of the last panel.
44243
The user will click the '+'and I will add another communication tab. The problem is, I want the active tab to be the
one that was just added in front of the tab with the '+'.

I can only use this.getTabPanel().add(newTab) if I am able to change the tab order after it has been added. Is this possible?

friend
7 Jun 2013, 9:00 AM
Inserting shouldn't be a problem, I just used add() because it was easier to type.

Try this:



onAddNewTab: function(){
var newTab = Ext.create('App.view.tools.CommunicationTab', {
title: 'Communication ' + this.getCount()
});
this.getTabPanel().insert(this.getTabPanel().items.length -1, newTab);
this.setCount(this.getCount() + 1);
this.getTabPanel().setActiveTab(newTab);
},

iamcootis
7 Jun 2013, 9:46 AM
I've already tried that. It doesn't work.

team.avesta
8 Jun 2013, 12:23 AM
You simply try this code:



var newTab = Ext.create('App.view.tools.CommunicationTab', { title: 'Communication ' + this.getCount() }).show();
No need to do setActiveItem and blah blah..
.
Tell me if it works for you.

evant
8 Jun 2013, 6:20 PM
You didn't post all the relevant code, how is the listener bound?