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 color of a butt...
Power Apps
Unanswered

Change color of a button after button is clicked

(0) ShareShare
ReportReport
Posted on by 46

I have a gallery with a complete button.  When someone clicks on the complete button, I want the button to turn to blue.  Right now,

Galleryname:  gal_Assignment

button name:  btn_Completed

I have set variable on select:  UpdateContext({ toggleValue: !toggleValue })

Then I changed the fill for the button to:  If(toggleValue, Color.Blue, Color.Green)

 

When I run the app and click on the button, all completed buttons in the gallery turn blue.  that is not what I want.  I only want thisitem.completed to turn blue.  Let me know if you think a screen shot would help

 

How do I change this to make that work?

 

 

Categories:
I have the same question (0)
  • TheRobRush Profile Picture
    11,128 Moderator on at

    Here's one way. 

     

    I made a gallery, and made it's items [1,2,3,4,5,6,7,8]

     

    In this gallery I placed a button with the OnSelect of 

    Switch(
     CountRows(Filter(examplebutton, Value=ThisItem.Value)),
     0, Collect(examplebutton,ThisItem.Value),
     RemoveIf(examplebutton,Value=ThisItem.Value))
    

     

    I also set its fill value to

    Switch(CountRows(Filter(examplebutton, Value=ThisItem.Value)),
     0, Color.Pink,
     Color.Blue)

     

    This will change button color, as clicked, for each gallery row individually, and also let you click a second time to unclick it.

  • ashajohn2021 Profile Picture
    46 on at

    I'm am such a beginner to power apps.  This looks really cool, but I  don't know what it's doing.  Currently for the onselect property, I'm doing a patch to the sql database (see below patch):. 

     

    The completed button should patch to the database and change colors to indicate that it has been patched.  I probably haven't thought this thru very good because, what if they need to change something and then click the button again.  The user wants a way to flag the user that they have actually clicked the button, but they also want to be able to click the button multiple times if changes need to occur.  How would you do this?  There is a field in the database for completed.  I was not sure what you value = thisitem.value should be referring to.  

     

    Patch(CaseAssignment,ThisItem,{Note:txt_Note.Text},
    {needpatdemos:chk_NeedPatientDemos.Value},
    {newfacility:chk_NewFaciliy.Value},
    {newneph:chk_NewNeph.Value},
    {whichneph:chk_WhichNeph.Value},
    {needneph:chk_NeedNeph.Value},
    {needinsurance:chk_NeedInsurance.Value},
    {oncallpath:chk_Oncallpath.Value},
    {othercs:chk_OtherCS.Value},
    {otherpath:chk_OtherPATH.Value},
    {surgicalquestion:chk_SurgicalQuestion.Value})

  • ashajohn2021 Profile Picture
    46 on at

    could you explain what your code is doing?  I dont understand it.  sorry 😞

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Here is how those examples work.

     

    
    ///A switch checks the value of something, and when a condition is met returns that action
    Switch(
     //Check for the value of this gallery item in a collection
     CountRows(Filter(examplebutton, Value=ThisItem.Value)),
     ///If it is not there, add it
     0, Collect(examplebutton,ThisItem.Value),
     ///If it is, remove it (this allows them to unchange the color of the button
     ///and can be removed if you don't want them to be able to
     RemoveIf(examplebutton,Value=ThisItem.Value))

     

    Switch(
    ///checks if this item was collected (has been pressed)
    CountRows(Filter(examplebutton, Value=ThisItem.Value)),
    ///If not color button pink
     0, Color.Pink,
    ///If this is not true, then the adverse is which means it has been pressed and we color it blue
     Color.Blue)

     

    It's self contained in the app itself, so if they close the app and reopen it later down the road the buttons will allr eturn to their default color of pink.

     

    If you want to PERMANENTLY for rest time change button colors when that item has been selected you will need to swap that collect action, into a patch of that item onto a sharepoint list that has a single text column that can store this value over time.

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
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard