PDA

View Full Version : Ext.Component.findParentByType (supporting inheritance seach)



plalx
29 Mar 2010, 7:32 AM
The current findParentByType method doesn't support inheritance search.
There are many cases where it is usefull to be able to find a parent by its parent class.
Here's a replacement for the native Ext.Component.findParentByType method.
This method is supporting inheritance search for class names and xtypes.



Ext.override(Ext.Component, {
findParentByType: function(type){
if (Ext.isFunction(type)){
return this.findParentBy(function(p){
return p instanceof type;
});
} else {
return (Ext.isFunction(Ext.ComponentMgr.types[type]))?
this.findParentByType(Ext.ComponentMgr.types[type]):
null;
}
}
});

superbinary
7 Apr 2011, 1:03 AM
it's really useful. thanks!~o)