20 Feb 2013 10:53 AM #1
Unanswered: Suggestion: change layouts dynamically
Right now you can't change a container's layout once you've instantiated it. I think it would be very helpful to be able to do this. Is anyone else interested in this ability?
This would be especially helpful with mobile sites, where you often need to rearrange things depending on the screen size and orientation.
I know you can create a new container with a different layout, and move the old one's items into it, which is what I've been doing. But this requires an extra container layer (if you want a component to be able to change its own layout), so it's not ideal.
20 Feb 2013 11:16 PM #2
This is the number 1 reason why whenever I develop a sencha touch app, I support landscape OR portrait in each profile, but never both... imagine being able to switch from a vbox (portrait) to hbox (landscape) on each orientationchange event. Any plans, Sencha?
20 Feb 2013 11:21 PM #3
Actually, in that particular case, you can essentially convert hbox to vbox by calling this.getLayout().setOrient('vertical'). But I'd really like to convert between the default layout and hbox/vbox.
20 Feb 2013 11:23 PM #4
You can? Cool, will look into that! Last time I tried was a while ago.
What's your use case for this other than orientation change? I prefer to use profiles and define layouts differently on subclassed views rather than programmatically changing the layout type.
21 Feb 2013 8:34 AM #5
I'm using it for orientation too. But with the multiple-profile approach, doesn't that mean you're stuck with whichever orientation you started in? Or do you switch profiles and re-create the views when you rotate the device?
I'd prefer not to destroy and re-create the views at all, since it means I have to restore their state too (for example, values of form fields).
21 Feb 2013 8:38 AM #6
Since all the apps I do right now are native ones, I don't bother with multi orientation at all! As with native apps you can restrict the user to a single orientation. I just have one profile per device-type.
This isn't ideal at all and I wish there was an easier way of doing this task in the framework.