View Full Version : GroupTabPanel.getActiveTab() does not return a Component (as some would expect).

1 Aug 2009, 8:49 AM
Ext 3.0 API Docs (http://extjs.com/deploy/dev/docs/source/TabPanel.html#method-Ext.TabPanel-getActiveTab) generated based on this code:

* Gets the currently active tab.
* @return {Panel} The active tab
getActiveTab : function(){
return this.activeTab || null;
Where in fact the returned value is not of Panel type, but rather string/number:

* @cfg {String/Number} activeTab A string id or the numeric index of the tab that should be initially
* activated on render (defaults to none).
activeTab : null,

1 Aug 2009, 8:53 AM
This is the thread for Ext Core. Not ExtJs.

Also that is wrong. You have not tested it have you?

1 Aug 2009, 9:04 AM
Oops... Sorry for posting on the wrong forum...

The following code:

tabGroup = this.getComponent('tabgroup'); // tabgroup is of xtype: grouptabpanel
Generates the following in FireBug:

<li id="ext-comp-1008__ext-comp-1010" class="x-tab-with-icon x-grouptabs-strip-active">

I am probably doing something wrong here, but anyway, just by looking at the code of Ext.TabPanel it doesn't seem that getActiveTab() returns a Panel...

1 Aug 2009, 9:10 AM

That's not TabPanel, the thing you linked to the documentation of.

1 Aug 2009, 9:20 AM

This is my wrong. There are actually two issues I'm referring to in this thread:
The documentation of TabPanel, which could suggest that getActiveTab() returns a Panel, while the code itself is documented with activeTab as string/number (as mentioned in my initial post). I haven't tested it and probably wrong.
The getActiveTab() of GroupTabPanel, which for some reason returns a string rather than Panel. See following code:

getActiveTab : function() {
if(!this.activeGroup) return null;
return this.activeGroup.getTabEl(this.activeGroup.activeTab) || null;
this.activeGroup.activeTab is actually a Component... not sure what getTabEl is for... I have expected it to return a Component like TabPanel...

So to summerize:
Very possibly I was wrong saying there is a documentation issue with TabPanel.
GroupTabPanel.getActiveTab() does not return a Component (as some would expect).Thanks

1 Aug 2009, 9:38 AM
getTabEl returns an HTML element.

GroupTabPanel.getActiveTab returns the getTabEl value. It is not documented at all!

It's not the same as TabPanel. I don't know why it does what it does, that's the author's decision.

ANyway, there's no doc bug. If you have a problem using it, post a help thread.

1 Aug 2009, 3:16 PM
I moved this set of posts to their own thread in HELP for time being so it could be discussed separately. Seems that consensus here might be that the GroupTabPanel implements the getActiveTab inconsistently, is that correct?

1 Aug 2009, 3:47 PM
GroupTabPanel.getActiveTab() returns a string rather than a component (which is what I'd expect).

I have been integrating GroupTabPanel into a web application I'm writing and there are a few slightly odd things about it. Perhaps I'm not using it in the right way, but consider this:

In my case I have an hierarchy as such:
Password There are no associated pages to 'Book' or 'Settings' - they are just categories. (I mark them as disabled, but wish that like with TabPanel that would prevent them from being selected - currently selecting a disabled GroupTabPanel shows an empty masked gray area.)

Then, I wish to have 'Room' as the activeTab when the component is rendered, but it does not seem to be possible with the current code. Having mainItem:1 will cause 'Room' to become the parent of 'Book' - not my intention.

Since getActiveTab does not return a component. The most logical way I've managed to do this is:

// a hack to get a sub item of GroupTabPanel selected
Ext.getCmp('my-grouptabpanel').on('afterrender', function(){
t = Ext.getCmp('initial-active-tab');
Which is a piece of an awkward code if you ask me.


1 Aug 2009, 10:32 PM
It doesn't return a String, it returns an HTML element. The tab strip item.

But I think after a glance at the code that this is GroupTabPanel, it's the active group's tab el. That's valid.

You need to get the activeGroup from the GroupTabPanel (There's no getter!)

Then get the activeTab from that.

This is all a little inconsistent and undocumented, and if these are official UXs, and are going to be added into the doc centre, this needs cleaning up.