开发者

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.

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;
}
It takes panel (container) as a parameter and returns all children and subchildren recursively.

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜