Pages

Friday, January 6, 2012

An easy way to get a reference to the viewport from any controller

Here's an easy way to get a reference to your viewport from any controller:

Ext.application({

  launch: function(){

    this.viewport = Ext.ComponentQuery.query('viewport')[0];


    this.centerRegion = this.viewport.down('[region=center]');

  }

});

then, inside say, a controller, you can call this:

this.application.viewport

to get a reference to the viewport.

6 comments:

  1. I spent way too much time trying to make sense of how to get access to MVC objects outside of the objects themselves. Your example helped me get there. Thanks!

    ReplyDelete
  2. how can i change viewport which is im application launch function dynamically with new viewport which is in my controller? Thanks

    ReplyDelete
  3. another way to get references to viewport is, since Ext.application inherits from Ext.controller, use refs to get references.

    ReplyDelete
  4. Had a need for this today and wanted to say - Thanks!

    ReplyDelete
  5. this is helpful

    thanks

    ReplyDelete