cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
UB400
Level 10

hide gallery item based on value

I have a flexible height Text Gallery, the DataSource for this Gallery has several fields. I'm using one of these fields as the name of a group of Users. I would like to hide or show Gallery items (not just individual textboxes) based on the value of one of the fields in the Gallery.

 

For example one of the textboxes is linked to a field called group, if the value of group=admin then hide item. In addition to that, I would also like to highlight the item using template fill, so something like If group=admin, then template fill is blue.

 

Any suggestions, under what property would I place the code? 

2 REPLIES 2
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: hide gallery item based on value

You can hide/show items from the data source in your gallery by using a filter expression in the gallery's Items property that filters out those that you don't want. For example, for this data source:

 

ForumPost101.PNG

I have this application, with a listbox showing some categories to display in the gallery, and the items in the gallery itself:

ForumPost102.PNG

Those are the formulas that I've used to show/hide items in the gallery, and to change the template fill depending on the data itself. You can see the expression using the If function to highlight the items depending on a value a property in the data row.

ListBox1.Items: Distinct(Races, Distance)
Gallery1.Items: Filter(Races; Distance in ListBox1.SelectedItems.Value)
Gallery1.TemplateFill:
    If(ThisItem.Distance = "Marathon",
        RGBA(127, 255, 127, 0.5),
        If(ThisItem.Distance = "1/2 marathon",
            RGBA(255, 255, 127, 1),
            If(ThisItem.Distance = "10 Km",
                RGBA(27, 127, 255, 0.2),
                RGBA(0, 0, 0, 0.1))))

Hope this helps!

Phobos
Level: Powered On

Re: hide gallery item based on value

I would like to apply this to controls in the gallery as well. 

I have a table that has a field to show/hide a control, and I would like to use that to manage what controls show up in each line item of the gallery. 

in the image below, the "true/false" next to the toggle is what I would like to use to either show or hide the toggle. 

gallery_example.JPGContextually show/hide controls

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 257 members 5,112 guests
Please welcome our newest community members: