How to get child element in ExtJS 4
How to get all the child elements or id of开发者_StackOverflow中文版 a Panel in ExtJS 4?
I wrote that function for you. I think it will help you.
It takes panel (container) as a parameter and returns all children and subchildren recursively.
function getAllChildren (panel) {
/*Get children of passed panel or an empty array if it doesn't have thems.*/
var children = panel.items ? panel.items.items : [];
/*For each child get their children and concatenate to result.*/
Ext.each(children, function (child) {
children = children.concat(getAllChildren(child));
})
return children;
}
EDIT
This will return ids of children. USES PREVIOUS FUNCTION - getAllChilden
function getAllChildenIds(panel) {
//*Get all child items. \*/
var children = getAllChilden(panel);
//*Replace items with their ids.\*/
for (var i=0, l=children.length; i < l; i++) {
children[i] = children[i].getId();
}
return children;
}
Just call query() on your panel which will return an array of all child elements which match an optional selector. i.e. panel.query()
精彩评论