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
    47
    Answers
    3
    Vote Rating
    3
    damo is on a distinguished road

      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

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar