PDA

View Full Version : Hiding all items: is there a count function?



Gunmen
14 Feb 2010, 8:16 AM
Hi,

I have multiple tabs in a tabpanel, but don't need them visible all at once.

What's the best way to hide them all?

I'm thinking of counting the number of items in the tabpanel and then use a loop. My question: is there a count function to get the number of added tabs? I tried the documentation but ended up with no results.

Little example:


Ext.getCmp('myTabPanelId').hideTabStripItem(i);


Thanks!

bclinton
14 Feb 2010, 11:00 PM
TabPanel has an items attribute which is an Ext.util.MixedCollection. Ext.util.MixedCollection has a getCount() method.

so,

Ext.getCmp('myTabPanelId').items.getCount();

Gunmen
15 Feb 2010, 9:51 AM
Oh, thanks. The documentation search did not came up with that result.

A performance question: When I add the getCount() in a for statement, how many times is the getCount() function executed? One time or each loop until the max count?



for (i=0;i<=Ext.getCmp('myTabPanelId').items.getCount();i++) {


Thanks!

Eugen_
15 Feb 2010, 10:31 AM
Hi Gunmen,

offtopic, sorry:

Why you don't use the each method? Something like this:


Ext.getCmp('myTabPanelId').items.each(function(tab) {
tab.hide();
});

Gunmen
15 Feb 2010, 11:06 AM
Hi Gunmen,

offtopic, sorry:

Why you don't use the each method? Something like this:


Ext.getCmp('myTabPanelId').items.each(function(tab) {
tab.hide();
});



Not offtopic, good idea.
I tried the idea before but it did somehow not work.