cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DevMolly100
Regular Visitor

How to disable selected items inside gallery ?

I have a gallery which will display the available time in white and  the non-available time in grey. However, I would like to disable all the colors that are grey to prevent the users from selecting that specific time slot. Is this possible ?

 

In the gallery button, I set the button color to this:

 

If(
ThisItem.Name in CollectionFakeHours.Name,
RGBA( 77,168,184,100),
RGBA( 187, 187, 187, 100)
)

 

However, instead of making the non available colors grey, I would rather have them disabled instead.   

 

Thanks !

 

3 REPLIES 3
Drrickryp
Super User
Super User

Hi @DevMolly100 

You can do that using the DisplayMode property of the button.  Set your condition for it to be either Edit or Disabled. 

If(condition1=Somevalue,Disabled,Edit)

 

TiagoFreire
Continued Contributor
Continued Contributor

You cannot disable the items strictly speaking, but you can work around it. (You can't reference ThisItem directly on the Gallery Item Template's DisplayMode)


Without knowing more of your app, it's hard to tell the best way. 

The selected item is probably being referenced by other objects or a Form. 

 

One way around would be to completely cover your gallery item (inside the item, so it repeats per item) with a blank label, ordered on top, which would NOT have a Select(Parent) action. Make rules on the height and width of this label. On enabled items, the height and width of this label would be 1,1. On disabled items, it would be Parent.TemplateWidth and Parent.TemplateHeight, making it impossible to trigger OnSelect(). 

 

Or, you can change the Gallery OnSelect populate a variable, a set, or ClearCollect() the selected item into an intermediate collection, and have your other objects or forms look at that instead. Your OnSelect would be conditional, so it only populates if certain conditions are met. 

 

The first is simpler as you only add 1 object to the gallery item, but the second provides more variables which may end up being more useful/flexible in the long run.

AlixCalon
Frequent Visitor

Check out this other thread discussing this same topic. I followed @VijayTailor's suggestion 

https://powerusers.microsoft.com/t5/Building-Power-Apps/Disable-item-in-gallery/m-p/886937#M281623


Grouping the gallery item fields worked great for me. I was able to change gallery items that were updated to DisplayMode.Disabled. I grouped everything in the gallery item and set a conditional statement for its display mode - If('Text' in Table.Column, DisplayMode.Disabled, DisplayMode.Edit). So, if the 'text' from my gallery item appears in the updated column of my separate update table then that gallery item will be disabled. Good luck!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (1,167)