cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tiksha
Helper II
Helper II

Conditional Visibility using switch case

Hey people, 

I have created gallery control with items in it:

["Vehicle Inspection","Fluids","Hoses"]

I have created the containers , so as if we click any item from gallery control the corresponding container will be shown on the screen.

By default set the visible property of screen false:

 

UpdateContext({conFluidVisible:false,conVehInspectVisible:false})

 

Set the OnSelect property  of button control of gallery :

 

If(
    ThisItem.IsSelected,
    Switch(
        ThisItem.Value,
        "Fluids",
        UpdateContext ({conFluidVisible: !conFluidVisible}),
        "Vehicle Inspection",
        UpdateContext({conVehInspectVisible:true})
    )
)

 

Now the problem I'm facing is, how to set visible property of all container false, else the container which is active (active here means the button clicked by user from gallery item). As all the containers are getting collapsed with each other when clicked on different gallery items.

 Please help

 Thanks in advance:)

1 ACCEPTED SOLUTION

Accepted Solutions
jinivthakkar
Super User
Super User

@Tiksha I found an easier way to do this 

 

Gallery button or > in my case - 

Onselect - Set(Var,ThisItem.Value);Clear(ColVar);Collect(ColVar,Var)

 

Container 1 

Onvisible - If("Vehicle Inspection" in ColVar,true)

 

Container 2 

If("Fluids" in ColVar,true)

 

Screen

OnVisible - Clear(ColVar)

 

Hope this helps.

 

--------------------------------------------------------------------------------

If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

View solution in original post

4 REPLIES 4
AJ_Z
Super User
Super User

Do you mean the datacards in the form if so each datacard has an individual visible property 🙂



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

Tiksha
Helper II
Helper II

@AJ_Z , Instead of data card I have used the containers and sets there visible property as :

 ConFluid visible property  as conFluidVisible  and ConVehicleInspection visible property as conVehInspectVisible:

But I'm unable to set visible property of the following variable false/hide as soon as user clicks the another button of gallery control.

The containers are collapsing with each other

As I what I want is if user clicks the gallery item(button1), container1 will be shown, if clicks item(button2),container2 will be visible and so on.

 

jinivthakkar
Super User
Super User

@Tiksha I found an easier way to do this 

 

Gallery button or > in my case - 

Onselect - Set(Var,ThisItem.Value);Clear(ColVar);Collect(ColVar,Var)

 

Container 1 

Onvisible - If("Vehicle Inspection" in ColVar,true)

 

Container 2 

If("Fluids" in ColVar,true)

 

Screen

OnVisible - Clear(ColVar)

 

Hope this helps.

 

--------------------------------------------------------------------------------

If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

Thank you so much @jinivthakkar , Yes it worked for me 🙂 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,374)