PDA

View Full Version : How to switch view with MVC router / controller?



glarotech
23 Mar 2011, 6:41 AM
Hi

I'm trying to use the Sencha router to switch the item/tab of the Viewport (TabPanel).
I connect to http://FQDN/#category/123

Here's my setup.

Router:

Ext.Router.draw(function(map) {

map.connect('category/:id', {controller: 'catalogList', action:'showCategoryRequestedByController'});

});

Controller (catalogList):

Ext.regController("catalogList", {
...
showCategoryRequestedByController: function(object) {
MobileShop.Viewport.setActiveItem('ppsCatalogView');
this.showCategory(object.categoryID);
},

Viewport:

MobileShop.Viewport = Ext.extend(Ext.TabPanel, {
...
items: [
{ xtype: 'ppsHomeView' },
{ xtype: 'ppsCatalogView' },
{ xtype: 'ppsBasketView' }
],
...
});


ppsCatalogView:

MobileShop.views.Catalog = Ext.extend(Ext.Panel, {
...
id: 'ppsCatalogView',
...
});

Ext.reg('ppsCatalogView', MobileShop.views.Catalog);

Any ideas how to get the catalogList/showCategoryRequestedByController() method getting to switch the Viewport item?

- domi

gordonjl
23 Mar 2011, 4:19 PM
The view won't show unless it, or a parent, has

fullscreen:true
Set. If it isn't, you will see a blank screen. Try putting it on your viewport.

glarotech
28 Mar 2011, 12:09 AM
hi gordonjl

thank you for your response.

fullscreen is already set in viewport.
the webapp is working properly, but I couldn't switch the view via controller (only via click).
but I've found a solution, which is working for me:


showCategoryRequestedByController: function(object) {
Ext.getCmp('viewport').setActiveItem('ppsCatalogView');
Ext.getCmp('ppsCatalogView').setActiveItem('ppsCatalogListView');
this.showCategory(object.categoryID);
}

- domi