hide unhide a view in a viewstack

royjayd
royjayd used Ask the Experts™
on
hi guys

I have a viewstack like this

<mx:ViewStack id="workflowViewStack" width="100%" borderColor="#000000" cornerRadius="4" selectedIndex="{modelviewdata.workflowviewstate}">              
<projectNavigation:ProjectProfileView label="Project Profile view" />            
<workflowNavigation:WorkflowView label="modelviewdata.id}" height="3000" width="3000" />
</mx:ViewStack>      


I want to hide and unhide this <workflowNavigation:WorkflowView> view. any idea how i can do it?

Something like

<mx:ViewStack id="workflowViewStack" width="100%" borderColor="#000000" cornerRadius="4" selectedIndex="{modelviewdata.workflowviewstate}">              
<projectNavigation:ProjectProfileView label="Project Profile" />      

if modelviewdata.showworkflowNavigation == "true" show it , else hide it            
<workflowNavigation:WorkflowView label="modelviewdata.selectedWorkflowid}" height="3000" width="3000" />      
</mx:ViewStack>      

thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2011

Commented:
The first, if you are using ViewStack you don't need to set children containers size its will takes full area of ViewStack. To easy handle you problem create a third container (dummy) and change index to that container :)

<mx:ViewStack id="workflowViewStack" width="100%" borderColor="#000000" cornerRadius="4"
                          selectedIndex="{modelviewdata.showworkflowNavigation == true ? modelviewdata.workflowviewstate : 2}">
            <projectNavigation:ProjectProfileView label="Project Profile view" height="100%" width="100%"/>
            <workflowNavigation:WorkflowView label="modelviewdata.id}" height="100%" width="100%" />
            <mx:Canvas height="100%" width="100%"/>
      </mx:ViewStack>

Author

Commented:
<mx:ViewStack id="workflowViewStack" width="100%" borderColor="#000000" cornerRadius="4"
 selectedIndex="{modelviewdata.showworkflowNavigation == true ? modelviewdata.workflowviewstate : 2}">
 <projectNavigation:ProjectProfileView label="Project Profile view" height="100%" width="100%"/>
  <workflowNavigation:WorkflowView label="{modelviewdata.id}" height="100%" width="100%" />
   <mx:Canvas height="100%" width="100%"/>
  </mx:ViewStack>


actually i have to display two labels
label="Project Profile view"   is always displayed no matter what

only the view <workflowNavigation:WorkflowView> and its label {modelviewdata.id} needs to be conditionally displayed if modelviewdata.showworkflowNavigation == true
so i think your code is not good for my scenario.

is there any way we can explicitly say something like

if (modelviewdata.showworkflowNavigation == "true") {
<workflowNavigation:WorkflowView label="modelviewdata.selectedWorkflowid}" height="3000" width="3000" />      
}
else{
hide
}
</mx:ViewStack>    

thx
Top Expert 2011

Commented:
ViewStack is not displaying labels, you have to use TabNavigator component
If you would like to hide you can use includeInLayout and visibile false attribute

Author

Commented:
ok...got it , one final question

I have
<workflowNavigation:WorkflowView  label="{modeldata.doesflowExist ==  false ? 'Create New Flow' : modeldata.showWorkFlow == false ? ' ' : modelviewdata.selectedWorkflowid}" height="3000" width="3000"  />      

 if modeldata.showWorkFlow  is false I want to avoid ' '  in above statement which is  causing a blank space in my view. i tried
<workflowNavigation:WorkflowView  label="{modeldata.doesflowExist ==  false ? 'Create New Flow' :modeldata.showWorkFlow == true ? modelviewdata.selectedWorkflowid}"height="3000" width="3000"  />

but i end up getting a error :expecting colon before right paren.

any idea how i can fix this?

thanks v much.

Top Expert 2011
Commented:
Use parentheses to avoid such confusions :)

<workflowNavigation:WorkflowView label="{(modeldata.doesflowExist == false ? 'Create New Flow' : (modeldata.showWorkFlow == true ? modelviewdata.selectedWorkflowid : ''))}" height="3000" width="3000"  />      
      

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial