-
13 Nov 2012 10:51 AM #1
Answered: Change a vbox into a hbox and vice versa on orientation change
Answered: Change a vbox into a hbox and vice versa on orientation change
Hi there,
I've built a horizontally scrollable hbox layout container, docked on top, filled with other sub-containers, which I want to transform into a vbox layout (scrollable vertically, docked to the left) on orientation change.
Right now I'm doing something like this on resize:
It kinda does what it's supposed to (it snaps to the left / top, becomes vertically / horizontally scrollable, sets the correct width / height), EXCEPT re-aligning the sub-containers properly - they either remain aligned horizontally (if the initial view was landscape) or vertically (for initial portrait view).Code:var hboxLayout = Ext.getCmp('hboxLayoutID'); Ext.getCmp('hboxLayoutParentID').removeAll(false, true); if(Ext.Viewport.getOrientation()=='landscape'){ hboxLayout.setDocked('left'); hboxLayout.setLayout({ pack: 'center', type: 'vbox' }); hboxLayout.setScrollable({ direction: 'vertical' }); hboxLayout.setHeight('auto'); hboxLayout.setWidth(100); }else{ hboxLayout.setDocked('top'); hboxLayout.setLayout({ pack: 'center', type: 'hbox' }); hboxLayout.setScrollable({ direction: 'horizontal' }); hboxLayout.setHeight(100); hboxLayout.setWidth(''); }; Ext.getCmp('hboxLayoutParentID').add([hboxLayout]);
Am I missing something / doing something wrong?
-
Best Answer Posted by Kurt001
No. 1:
You may create two views and show the other view on the fly (destroying the first if you need to)
No. 2:
You create two containers in the main container. One with hbox and the other with vbox.
Then you transfer the content to the other container as needed.
The second is especially good if you have forms and do not want to loose the selections/entered text.
-
15 Nov 2012 6:09 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3157
Changing layout on the fly is not currently supported.
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.
-
15 Nov 2012 6:21 AM #3
You could rebuild the view onOrientationChange like this:
Rebuilding usually can be done on the fly without any interruptions.Code:xtype: 'container', layout: { pack: 'center', type: Ext.Viewport.getOrientation()=='landscape' ? 'vbox' : 'hbox' }
-
16 Nov 2012 5:08 PM #4
-
17 Nov 2012 4:01 AM #5
two ways
two ways
No. 1:
You may create two views and show the other view on the fly (destroying the first if you need to)
No. 2:
You create two containers in the main container. One with hbox and the other with vbox.
Then you transfer the content to the other container as needed.
The second is especially good if you have forms and do not want to loose the selections/entered text.
-
17 Nov 2012 11:32 AM #6


Reply With Quote