Search code examples
extjs4extjs4.1

ComponentQuery for a parent with ExtJS4?


Is there a way to query "up"? I'm in a Component and want to register listeners to it's parents events with control(). This requires a Query which gets me the parent of my main view.


Solution

  • In ExtJS4, you can use 'up()' from an Ext Element.

    The params are a string of the parent element you wish to find e.g:

    var parentEl = Ext.get('childID').up('div.parentClass'); 
    

    If you provide some details about the structure of your components/elements I can give a specific example which should fit.

    EDIT: To show going 'up' from a component

    var myComponent = // however you've got it
    
    var theParentEl = myComponent.getEl().up('div.parentClass');