View Full Version : Why is it items.items?

29 Dec 2009, 8:41 AM
I am looping through the panels loaded into a TabPanel and I was just wondering why the actual items collection is nested inside another property called items?

I loop through the panels like this:

for (var i=0; i < tabPanel.items.items.length; ++i)
var pnl = tabPanel.items.items[i];
// do something with pnl

The TabPanel appears to have a property called "items" which itself contains a property called "items" which is an array of the panels. Am I doing something wrong?

29 Dec 2009, 9:05 AM
because items is an instance of Ext.util.MixedCollection, which itself has an items property to store the references.

Check out the source code for Ext.Container

29 Dec 2009, 10:05 AM
You could alternatively do this:

var pnl = item;

Mike Robinson
29 Dec 2009, 3:38 PM
The second approach just mentioned is definitely "the best way to do it," imho. It treats the items property as "an opaque thing," without delving into what is, strictly speaking, an artifact of its present-day implementation.

items "is a" MixedCollection, and so the best approach is to use the provided methods of a MixedCollection to deal with it.