View Full Version : Understanding NavigationView Better
17 Feb 2012, 8:33 AM
I am using Sencha Touch in Sencha Designer. I created a NavigationView which is marked as the initialView. I created two containers, LoginContainer and RegistrationContainer which are siblings in the project to the NavigationView. I created a controller that has a Controller Action bound to my NavigationView's show event (called it onShow).
So in onShow I want to make a decision of which container (Login or Registration) should be pushed onto the NavigationView. Watching the intro video I see that I need to make a link from my containers to my NavigationView. However when I link the two containers, the first one (in this case Login) gets loaded into the NavigationView automatically. So then if in onShow I decide to push the RegistrationContainer I get it, but it has a back button that takes you back to the LoginContainer.
What is the correct way to do what I want to do?
17 Feb 2012, 12:16 PM
You're heading down the right path for sure. What might not be obvious from the demo is that linking the view classes into the Navigation View is only necessary if you want them to be present at the start. It's completely valid to have your Navigation View be empty at the start, and dynamically push the first card into it when you choose.
I'm attaching a sample project that demonstrates, I think, what you're going for. You'll see that I've left the Navigation View without any children. All the juicy bits are in the 'launch' function of the controller. For the sake of demonstration I'm just choosing one container or the other at random, in place of your real logic. You'll also notice I'm using controller refs with autoCreate enabled for the login/registration components, so I don't have to manually instantiate anything. (See http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Controller for details on these advanced refs.)
I hope this helps get you where you want!
17 Feb 2012, 12:46 PM
Thanks, that explains it clearly.
20 Mar 2012, 12:28 PM
I'm new to ST and am hoping the new Designer will help me to understand the basics. I have been struggling with the navigation view and am hoping your example will help me out. I'm using build 188.8.131.521 and can't seem to open or import the posted xds file properly (an empty project opens). xda files from other examples open properly. Is there anything I can do to get this sample to load as an xds file or is it possible to convert it to a xda file (if that's the issue)?
Thanks in advance.
20 Mar 2012, 12:59 PM
@mamaatnl the internal project file format has changed since I posted that example, but your Designer should upgrade it automatically when you try to open it.
If for some reason that's not working, try renaming the .metadata directory to just metadata with no leading dot, then try opening the xds.
20 Mar 2012, 1:38 PM
Thanks for the suggestion. There's no (.)metadata file in the zip. To be sure I downloaded it again. What else can I do?
20 Mar 2012, 1:45 PM
Mac's Finder hides files/directories with a leading dot. You'll have to do this from a command line or with another tool that shows you hidden files.
20 Mar 2012, 2:43 PM
Got it to open now after renaming the folder from .metadata to metadata. Designer converted the project.
Thanks for your patience!
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.