1. #1
    Sencha User
    Join Date
    May 2013
    Posts
    3
    Vote Rating
    0
    _Scorpion_ is on a distinguished road

      0  

    Default Answered: Is getCmp the only way to get parent element from listener?

    Answered: Is getCmp the only way to get parent element from listener?


    Hi! In my project I've found some strange thing and I'm not sure if it's ok or not.
    I define class which extends 'Ext.tree.Panel' and have id='themesGrid'.
    I have several listeners defined like:

    Code:
    Ext.define('mypackage.MyTree', {
        extend: 'Ext.tree.Panel',
        id: 'themesGrid',
        ...
        initComponent: function () {
             Ext.apply(this, {
             ...
                    viewConfig: {
                        listeners: { //<- Here are listeners - "beforedrop", etc.
             ...
    And in these listeners I get parent TreePanel only using Ext.getCmp('themesGrid'), which looks "not right" for me. Can someone enlighten me and tell me if I'm wrong here?

  2. In your initComponent, create a reference var like

    Code:
    var me = this;
    Then inside listeners, use that ref ... for eg., me.yourFunction

  3. #2
    Sencha User
    Join Date
    Oct 2010
    Posts
    39
    Answers
    6
    Vote Rating
    5
    Piruthu is on a distinguished road

      1  

    Default


    In your initComponent, create a reference var like

    Code:
    var me = this;
    Then inside listeners, use that ref ... for eg., me.yourFunction

  4. #3
    Sencha User
    Join Date
    May 2013
    Posts
    3
    Vote Rating
    0
    _Scorpion_ is on a distinguished road

      0  

    Default


    Works great, thanks! I felt that something was wrong there...

Thread Participants: 1