cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
allenk
Frequent Visitor

Show/hide controls in gallery

I have a gallery that will be populated from a SharePoint list for performing audits.  I want to have a button next to the question that allows me to show/hide a text box and image upload control.  I can get the button to work, but it shows/hides the controls for all questions at once.  I need it to only show on the question it is pressed on.  Currently I have the visible field set to a variable 'v' with the string:

If(v=false, UpdateContext({v:true}), UpdateContext({v:false}))

in the OnSelect field for the button.

 

I've tried the ThisItem.IsSelected route, but it won't hide the control until I select the next question.  The button is essentially useless the way I was doing it.  Any help would be appreciated. 

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi@allenk,

Based on the issue that you mentioned, do you want to show/hide a text box and image upload control based on the button clicking?

Could you please share a bit more about the scenario?

I think that ThisItem.ID is the key to this problem.

Please set the OnSelect property of the Button as below:

Set(Var,ThisItem.ID);Collect(ColVar,Var)

Set the Visible property of the control as below:

If(ThisItem.ID in ColVar,true)

Hope it could help.

Regards,

Qi

Best Regards,
Qi

View solution in original post

allenk
Frequent Visitor

Update.  The OnSelect code worked, but, when I clicked to collapse on any individual gallery question, it would collapse them all.  This is the new statement that works perfectly:

OnSelect:

If(ThisItem.ID in ColVar,Remove(ColVar,First(Filter(ColVar,Value=ThisItem.ID))),Set(Var,ThisItem.ID); Collect(ColVar,Var))

Text Box Visible:

If(ThisItem.ID in ColVar,true,false)

View solution in original post

8 REPLIES 8
JR-BejeweledOne
Super User
Super User

You won't be able to use a variable in this manner.   To affect a control, icon or button in a single gallery row, you have to use the 'ThisItem' parameter.    Otherwise you will be affecting the entire gallery.

 

Is your gallery pulling directly from the data source or is it a collection that updates the data source later?



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

Ah.  That makes sense.  It will be pulling from the data source to populate the gallery questions/answers.

JR-BejeweledOne
Super User
Super User

What is your gallery items formula?



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
v-qiaqi-msft
Community Support
Community Support

Hi@allenk,

Based on the issue that you mentioned, do you want to show/hide a text box and image upload control based on the button clicking?

Could you please share a bit more about the scenario?

I think that ThisItem.ID is the key to this problem.

Please set the OnSelect property of the Button as below:

Set(Var,ThisItem.ID);Collect(ColVar,Var)

Set the Visible property of the control as below:

If(ThisItem.ID in ColVar,true)

Hope it could help.

Regards,

Qi

Best Regards,
Qi

View solution in original post

Interesting solution.   I will have to keep this in mind.  



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
JR-BejeweledOne
Super User
Super User

I haven't had to use it personally, but I do recall reading another post where the user was retrieving some data from SQL and was having a similar issue.  It turned out that in that case there were random numbers of white spaces being added and that was causing the issue.

 

Here is something you can use to verify that the number of characters in your vUserSolid is what you expect it to be.

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-len



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

This works perfectly for making it show up.  I just had to add an If to make it disappear. 

Button OnSelect:

If(ThisItem.ID in ColVar,Clear(ColVar),Set(Var,ThisItem.ID); Collect(ColVar,Var))

Text Box Visible:

If(ThisItem.ID in ColVar,true,false)

Couldn't have done it without you all.  Thanks a bunch.

allenk
Frequent Visitor

Update.  The OnSelect code worked, but, when I clicked to collapse on any individual gallery question, it would collapse them all.  This is the new statement that works perfectly:

OnSelect:

If(ThisItem.ID in ColVar,Remove(ColVar,First(Filter(ColVar,Value=ThisItem.ID))),Set(Var,ThisItem.ID); Collect(ColVar,Var))

Text Box Visible:

If(ThisItem.ID in ColVar,true,false)

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,522)