PDA

View Full Version : Working with TabPanel's items array



paulharv
7 Jul 2010, 3:52 AM
I created a tab panel, and then add tabs to it like this...


...
var tPanel = Ext.getCmp('myTPanel');
tPanel.add({
title : text,
id : text,
html : 'I\'m tab '+text+'!'
});
...
(This is in the context of an Ext.Msg.prompt handler function)

Then I iterate the tabpanel's items...

Ext.each(Ext.getCmp('myTPanel'), function(item){

// if I added 3 tabs, sure enough .each() loops 3 times
// but the value of "item" is undefined each time

})

Why are the tabs coming up as undefined?
I can see them and can select/disable/hide them programmatically.

Thanks

Condor
7 Jul 2010, 4:10 AM
Ext.each iterates over an array. Is Ext.getCmp('myTPanel') an array?

You want:

Ext.getCmp('myTPanel').items.each(function(item){
...
});

paulharv
7 Jul 2010, 8:39 AM
I'm sorry - my actual code is like this - but same thing, item is undefined...


Ext.each(Ext.getCmp('myTPanel').items, function(item){

// if I added 3 tabs, sure enough .each() loops 3 times
// but the value of "item" is undefined each time

})

Cheers

Animal
7 Jul 2010, 9:26 AM
And what is Container's items property? Is it an Array?

Condor gave you the correct code!

paulharv
9 Jul 2010, 3:37 AM
...shoot, thought I'd tried that and it had failed which led me to do Ext.each().
Thanks gents
Paul