1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    9
    Vote Rating
    0
    m00l is on a distinguished road

      0  

    Default Answered: How to access a Panel (in a View) from a controller

    Answered: How to access a Panel (in a View) from a controller


    Hey guys,


    i have a simple view:


    Code:
     Ext.define('gigadmin.view.RootLayout' ,{
            extend: 'Ext.panel.Panel', 
            layout: 'column',
            alias: 'widget.rootLayout',
            id: 'myRootId'
        });
    The thing i want to do is: Get a reference of the Panel (defined in the view) in my controller.


    My code:


    Code:
    Ext.define('gigadmin.controller.Root', {
        extend: 'Ext.app.Controller',
        views: [
            'RootLayout'
        ],
        
        init: function() {
            
            Ext.ComponentMgr.get('myRootId').add(
                {
                    ...
                }
            );
            Ext.ComponentMgr.get('myRootId').doLayout();
        }
    });
    But this doesn't work.

    Thanks for your help!

  2. Use Ext.ComponentQuery

    But looking at your example code, that kinda of behaviour should go in the class itself, otherwise the controller should be doing it off of an event. In that case use...
    Code:
    this.control({
         'rootLayout': {
                     afterrender: this.addStuffFunction             
         }         
    });

  3. #2
    Sencha User
    Join Date
    Jun 2009
    Posts
    102
    Answers
    8
    Vote Rating
    6
    campersau1 is on a distinguished road

      0  

    Default


    You have to specify refs in your controller like here: http://docs.sencha.com/ext-js/4-0/#!...app.Controller

    NOT tested!
    Code:
    Ext.define('gigadmin.controller.Root', {
        extend: 'Ext.app.Controller',
        views: [
            'RootLayout'
        ],
    
    
        refs : [{
            ref : 'rootLayout",
            selector : "rootLayout"
    
    
        }],
        
        init: function() {
           this.getRootLayout();
        }
    });

  4. #3
    Sencha Premium Member
    Join Date
    Oct 2009
    Location
    Leeds
    Posts
    64
    Answers
    6
    Vote Rating
    9
    damo will become famous soon enough

      0  

    Default


    Use Ext.ComponentQuery

    But looking at your example code, that kinda of behaviour should go in the class itself, otherwise the controller should be doing it off of an event. In that case use...
    Code:
    this.control({
         'rootLayout': {
                     afterrender: this.addStuffFunction             
         }         
    });

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi