web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : BfiMCpq4EhNiT79dn+ixRx
Power Apps - Building Power Apps
Answered

Controls Should Only be Visible in Specific Item of Gallery

Like (0) ShareShare
ReportReport
Posted on 7 Feb 2024 19:54:51 by 5,081 Super User 2025 Season 2

I have Gallery1, in which there is a 'Trash' icon that allows the user to delete that item in the gallery with  -
     Remove(Subscriber_Address_List,ThisItem)

There is a desire to provide a message that asks the user if they want to delete this item, to minimize unintended deletes. 

To that end, I have added a Label1 (with the message), and a 'Yes' and 'No' button.

The 'Yes' button now has the Remove(Subscriber_Address_List,ThisItem) formula, as well as Set(varDeleteControlsVisible, false).

The 'Trash' icon now has Set(varDeleteControlsVisible, true).

The 'No' button has Set(varDeleteControlsVisible, false).

My issue, when the 'Trash' icon is pressed the other controls appears in each item of Gallery1. Is there a formula I can use that when the 'Trash' icon is pressed the other control appear only in the item in which the 'Trash' icon was pressed and nowhere else?

Phineas_0-1707334948869.png

Phineas_1-1707335055027.png

 

Categories:
  • Kirkby Profile Picture
    647 Moderator on 08 Feb 2024 at 05:38:40
    Re: Controls Should Only be Visible in Specific Item of Gallery

    @Phineas  Great Job!!!  😎 

  • Phineas Profile Picture
    5,081 Super User 2025 Season 2 on 08 Feb 2024 at 05:25:46
    Re: Controls Should Only be Visible in Specific Item of Gallery

    I understand now.

    Userd UpdateContext({selectedItem:161616161}) and it worked.

    Thank you!

  • Verified answer
    Kirkby Profile Picture
    647 Moderator on 08 Feb 2024 at 04:45:12
    Re: Controls Should Only be Visible in Specific Item of Gallery

    What is the type of Data(ID)?

    As I mentioned in the above, If ID is not a text but a number, set a random integer that is not expected to come out from your data  instead

  • Phineas Profile Picture
    5,081 Super User 2025 Season 2 on 08 Feb 2024 at 04:43:54
    Re: Controls Should Only be Visible in Specific Item of Gallery

     "Incompatible types for comparison. These types can't be compared. Error, Error."

    I only had the formula to the 'Yes' button, as a test.

  • Kirkby Profile Picture
    647 Moderator on 08 Feb 2024 at 04:41:11
    Re: Controls Should Only be Visible in Specific Item of Gallery

    what is the error message?

     

  • Phineas Profile Picture
    5,081 Super User 2025 Season 2 on 08 Feb 2024 at 04:39:19
    Re: Controls Should Only be Visible in Specific Item of Gallery

    When I put UpdateContext({selectedItem:" "}) in the 'OnSelect' of the 'Yes' button I get an error in and the other two controls.

    Phineas_0-1707367038587.png

     

  • Verified answer
    Kirkby Profile Picture
    647 Moderator on 08 Feb 2024 at 04:27:55
    Re: Controls Should Only be Visible in Specific Item of Gallery

    UpdateContext({selectedItem:"NOTHING_SELECTED"}) //OnSelect of yes and no button

     

    Any value would work unless it is duplicated with keys in the list. An empty string ("") or meaningless "dkiwjidsdskewdwwew" would also work. That is like setting the visible value to false again as if no item has been selected yet.

     

    If ID is not a text but a number, set a random integer that is not expected to come out from your data  instead

     

    Kirkby

     

  • Phineas Profile Picture
    5,081 Super User 2025 Season 2 on 08 Feb 2024 at 04:05:37
    Re: Controls Should Only be Visible in Specific Item of Gallery

    Yes, sir.

    That's the ticket!

    One last; The 'Trash' icon has the following in the 'OnSelect' to control the visibility of those delete controls.

    I am now only seeing the controls in the specific item in which the 'Trash' icon is pressed.

    What code should be in the 'Yes' and 'No' buttons to hide them once the are clicked, returning the Gallery to its default state where delete buttons/label are hidden?

    Phineas_2-1707364702911.png

  • Verified answer
    Kirkby Profile Picture
    647 Moderator on 08 Feb 2024 at 03:33:05
    Re: Controls Should Only be Visible in Specific Item of Gallery

    varDeleteControlIsVisible is reflected uniformly across all items, so all delete controls will be displayed. The Visible property should be changed to True or False for each individual item at every single time by action of an user, so please enter "selectedItem = ThisItem.ID" instead of using the variable. 

     

    The result of logical expression, "selectedItem = ThisItem.ID" (Don't miss "selectedItem=", and Not ThisItem.Key....) decides Visible value to display the control. 

     

    Additionally, since the Delete control includes two buttons, it is cumbersome to manage the Visible property for each. Placing the Delete Control (with two buttons) in a Container "as a parent" and activating the Visible property of the container with selectedItem = ThisItem.ID would be more convenient. 

     

  • Phineas Profile Picture
    5,081 Super User 2025 Season 2 on 08 Feb 2024 at 02:50:39
    Re: Controls Should Only be Visible in Specific Item of Gallery

    Got it.

    Made that 'KeyOfTheItem' change to 'ID'.

    That error went away.

    However, my 'Delete' controls (Label1, 'Yes' and 'No' buttons) are still appearing on each line.

    The below represents what the Visible for each has in it.

    Phineas_0-1707359532311.png

    If I change the Visible to ThisItem.KeyOfTheItem I get errors. I'm sure this is not correct. What should the visible of each?

    Phineas_2-1707360432696.png

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2