-
28 Apr 2012 10:38 PM #1
best practice for MVC auto-creation of views with multiple profiles
best practice for MVC auto-creation of views with multiple profiles
I have an app with phone and tablet profiles. It has a view with a button that brings up another view. In the tablet version, this new view is simply a floating window shown next to the button. In the phone version, it is a whole screen that is switched to.
I'm trying to figure out what the best practice is for this situation. Is it to give each profile view a different xtype and then create two separate refs, one in each controller like:
phone controller:
tablet controller:Code:myView:{ selector:'someViewPhone', xtype:'someViewPhone', autoCreate:true },
?Code:myView:{ selector:'someViewTablet', xtype:'someViewTablet', autoCreate:true },
Then in the phone controller's click for the button:
and in the tablet controller:Code:Ext.Viewport.add(this.getMyView()); Ext.Viewport.setActiveItem(1);
?Code:this.getMyView().showBy(this.getMyButton());
Or is there some more elegant way to go about this?
-
30 Apr 2012 12:11 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
Each profile should have it's own controller. I usually have a base controller and have the phone/tablet controllers extend it so I can reuse that base code but put the profile specific logic in the profile controllers.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
30 Apr 2012 12:13 PM #3
Yes, mitchell, that's why I specified in my tablet that I have a phone and a tablet controller (along with the base one). My question was about what to do to create the controller-specific view. Check out my question again.
-
30 Apr 2012 12:19 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
Checkout my reply again. If you have a base controller that can handle say a button click but what happens on that button click is profile specific, now different controllers can take over.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
30 Apr 2012 12:21 PM #5
That's what I'm doing, mitchell. I'm not asking about the controllers so much as the VIEWS. Notice my question about having two different xtypes.
-
15 Aug 2012 11:53 PM #6
I think I understand what you mean and I believe you will find your answer there : http://www.sencha.com/forum/showthre...les-amp-xtypes


Reply With Quote