1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Vote Rating
    3
    Answers
    4
    matfin is on a distinguished road

      0  

    Default Answered: Accessing instance of view created with Ext.Define

    Answered: Accessing instance of view created with Ext.Define


    Looking at the following code

    Code:
    var mainpanel = Ext.define("App.view.Main", {
        extend: 'Ext.tab.Panel',
        xtype: 'mainpanel',
        id: 'mainpanel',
        config: {
        	fullscreen: true,
            tabBarPosition: 'left',
            items: [
                {
                    xtype: 'homepanel'
                }, 
               {
                	xtype: 'settingspanel'
                }
            ]
        }
    });
    How can I access the instance of this created panel ?


  2. #2
    Sencha - Training Team mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    691
    Vote Rating
    12
    Answers
    21
    mrsunshine will become famous soon enough

      0  

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    82
    Vote Rating
    3
    Answers
    4
    matfin is on a distinguished road

      0  

    Default Thanks

    Thanks


    Hi

    Thanks for the reply. That does indeed work (somewhat) and it caught me out when trying to access 'homepanel'. Here is how I refined it:

    -- Ext.ComponentQuery.query('homepanel'); - this returns an array of all components with the xtype 'homepanel' even if there is only one. Trying to access this directly won't work

    --
    Ext.ComponentQuery.query('homepanel')[0]; - this will access the actual 'homepanel' component directly, which is exactly what I needed.

    Another pitfall that caught me. When the function animateActiveItem() is called in the following way:

    Code:
    this.getMain().animateActiveItem(
    {
        xtype: 'homepanel'
    },
    {
        type: 'fade'
    });
    It creates another instance of the homepanel, so each time the above function is called (from a controller for example) it clones the homepanel. The correct way to do this would be as follows:

    Code:
    this.getMain().animateActiveItem(Ext.ComponentQuery.query('homepanel')[0], {type: 'fade'});


    Hope this helps others who run into this problem in the future.

    Thanks again,

    Matt

Thread Participants: 1

Tags for this Thread