Results 1 to 3 of 3

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

  1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    9
    Vote Rating
    0
      0  

    Default 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
      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
    66
    Answers
    6
    Vote Rating
    9
      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             
         }         
    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •