View Full Version : How to get reference to global Viewport if autoCreateViewport enabled?

31 Dec 2011, 7:34 AM
In my application, I have autoCreateViewport set to true. Is there a way to get a reference to this viewport since it was set globally by the application? I tried Ext.Viewport and this.getLayout in my controller click events, but neither worked. I am trying to do something like this in my one of my click events: Ext.Viewport.setActiveItem('productdetail'). I get this error though:

Uncaught TypeError: Object function constructor() {
return this.constructor.apply(this, arguments);
} has no method 'setActiveItem'

31 Dec 2011, 9:17 AM
create a ref in your controller:

refs : [
ref : 'viewport',
selector : 'app-viewport' //whatever the xtype is of your viewport class

Now in your controller you can do this.getViewport() and it should return your viewport instance.

1 Jan 2012, 7:17 PM
I was hoping for something built into the framework instead of having to re-wire these in every control. Since the app is the one creating it, it should be able to return the global viewport reference (just a humble suggestion/request). Your technique worked tho. Thx!