PDA

View Full Version : Is there an "children" equivalent to the "child" method?



da_b0uncer
17 Oct 2013, 6:26 AM
query() gets me all children, even the deeper ones, but child() only gets the first matching direct child.

aw1zard2
17 Oct 2013, 7:12 AM
You can get creative using the ComponentQuery.

For a certain panel you can give all fields an itemId with a prefix or suffix for that panel then query for that.
The $= will search for a match on suffix.


Ext.ComponentQuery.query('field[itemId$=mypanel-fld]');


This will bring back all fields that have the ending of mypanel-fld.
field1-mypanel-fld
field2-mypanel-fld
field3-mypanel-fld
field4-mypanel-fld

Look at the docs on Ext.ComponentQuery they give more examples.
Hope this helps.
:)

droessner
17 Oct 2013, 8:05 AM
You can also use the > operator to specify that you only want to query direct child components.

For example query('>panel') would return only direct child panels of a component.

aw1zard2
17 Oct 2013, 10:33 AM
I am using the itemId mixed with any button for toolbars to do a single click event for all buttons on all toolbars of that panel.



this.control('#myPanel > toolbar > button',{
click: this.btnClicked
});



btnClicked: function(btn){
switch(btn.itemId){
case 'tbar-b1-btn':
//some functional code mostly call another function.
break;
case 'tbar-b2-btn':
//some functional code mostly call another function.
break;
case 'bbar-b1-btn':
//some functional code mostly call another function.
break;
case 'bbar-b2-btn':
//some functional code mostly call another function.
break;
}
}