Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
157
rated 0 times [  158] [ 1]  / answers: 1 / hits: 18729  / 13 Years ago, mon, february 6, 2012, 12:00:00

How can I find if a particular child (item) exists in a panel using the id of the child.



Say I have a parent paned (id = parentPanel) and few panels as items of this parent panel. Now, I would like to search if a panel by id 'childPanel09' is a child of parent panel.



[Possibly without using iteration]



Note: I am using ExtJs 3.4


More From » extjs

 Answers
236

If you want to search only among direct childs of parentPanel you can use getComponent:



var childPanel = Ext.getCmp('parentPanel').getComponent('childPanel09');
if (childPanel) {
alert('yes. child exists');
}


If you want to search not only among direct childs but at any layer under the parentPanel you can use find:



var childPanel = Ext.getCmp('parentPanel').find('id', 'childPanel09')[0]; // [0] because find returns array
if (childPanel) {
alert('yes. child exists');
}

[#87625] Friday, February 3, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
anitadevonm

Total Points: 730
Total Questions: 93
Total Answers: 74

Location: Estonia
Member since Wed, Jun 8, 2022
2 Years ago
;