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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Change individual row ...
Power Apps
Answered

Change individual row fill colors in a gallery based on a button in that row

(0) ShareShare
ReportReport
Posted on by 674

I have a gallery with rows connected to a data source. I would like to change the template fill color of an individual row to green when a button in that row is pressed or the item is selected. I have been able to do this, but it will only change one row at a time to green, and the others remain the default blue color.  Once a row has been selected and turns green, I want it to stay green regardless of selecting another row. Any ideas on this? My code so far:

TemplateFill property for the gallery:  

If (ThisItem.IsSelected, RGBA(67, 245, 39, .8),
If(!ThisItem.IsSelected, RGBA(39, 174, 245, .8), RGBA(67, 245, 39, .8)
   )
)

 

I also have a button that does some other actions (in each row), so could add actions to the OnSelect property of the button as needed.

Categories:
I have the same question (0)
  • 55552 Profile Picture
    674 on at

    This worked!  The only addition in my case was that I have a dropdown control that a user selects a value, then the gallery is filtered by the dropdown answer. So I added Clear(CollectionName) here so that each time a new selection is made, the Collection is cleared.

  • LaurensM Profile Picture
    12,516 Moderator on at

    @TheRobRushno worries!

    I stand behind 'the more the merrier' 😉

  • TheRobRush Profile Picture
    11,128 Moderator on at

    sorry @LaurensM we crossed >.<

  • TheRobRush Profile Picture
    11,128 Moderator on at

    One Example

     

    Set your template fill to

    If(ThisItem in testRange, RGBA(0, 89, 178, 1), RGBA(0, 89, 178, 0)) 

    adjust colors as needed mine are just to test it out

     

    then onselect of each item should be

    If(ThisItem in testRange, Remove(testRange, ThisItem), Collect(testRange, ThisItem))
     
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Runner55552,

     

    You can achieve this by making the OnSelect of the gallery and/or the OnSelect of your button save a unique field of that item to a collection. In the example below, I am saving the ID field:

     

    Collect(colSelectedItems, ThisItem.ID)

     

    The Fill property of your items (TemplateFill) should be:

    If(
     ThisItem.ID in colSelectedItems,
     RGBA(67, 245, 39, .8),
     RGBA(39, 174, 245, .8)
    )

     

    If this solves your question, would you be so kind as to accept it as a solution.

    Thanks!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 428

#2
WarrenBelz Profile Picture

WarrenBelz 374 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 333 Super User 2025 Season 2

Last 30 days Overall leaderboard