0
votes

I am fairly new to Sencha Architect, as well as EXTJs. I have created an application with multiple Views (2 Containers). I am trying to switch views when clicking a button in container1. I have an event created which fires fine, what i don't know is how to switch to the next view? I've tried:

if(Ext.getCmp('mainView'))
{
    Ext.Viewport.setActiveItem(Ext.getCmp('mainView'));
}
else 
{
    var view = Ext.create('Snapwire.view.mainView');
    Ext.Viewport.setActiveItem(view);
} 

But this just throws a console error:

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

Thanks!

4
what contatiner are you using? Also which version of sencha? 1 or 2? - Abdel Raoof Olakara
I'm using a Ext.container.Container, Sencha 2, Architect 2 - Michael
are you using card layout? that is what you should be using - Abdel Raoof Olakara

4 Answers

1
votes

You can achieve what you want using navigation view Please check this link

http://docs.sencha.com/architect/2/#!/guide/navigationview

Hope it Helps ^^

0
votes

Ext.getCmp('mainView') only returns your main view if you set an id for it. In your class definition, add this config:

id: 'mainView'

0
votes

I did this way:

Ext.Viewport.remove(Ext.Viewport.getActiveItem(), true);  
Ext.Viewport.add([
 { xtype: 'searchwords' }
 ]);  

Here,

xtype:searchwords 

is an view called SearchWords where it is defined as

alias: 'widget.searchwords'

Hope it helps you.

0
votes

You can try using a card layout and change views with:

container.setActiveItem(1);

or

container.setActiveItem(0);

(all the containers must be added before you use setActiveItem but it will show only the active item)