cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

Checkboxes in gallery keeps refreshing when typing something in "search" textbox

Hi everyone. I have checkboxes incorporated in my gallery and a textbox which serves as "employee name search box".

The checkboxes allows users to select multiple rows and save them by batch. This is working just fine until I decided to type in something in the searchbox. The gallery searches for the employee but the initial items selected by the user got refreshed. All items selected by the users got unchecked.

Is there a way to not refresh/reset the checkboxes when the user searches for an employee name?

I have a filter in my gallery "textboxsearch.text in empnamecolumn"

 

1 - I select multiple items

1.png

 

2- I search for a particular employee name

2.png

 

3 - initial checked selection are gone when I clear the searchbox

3.png

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps
Power Apps

Hi @keihimekawa ,

It sounds like:

  • You have a gallery for making selections.
  • The gallery's items change as the text in the search box changes.

 

In a scenario involving selection of items, it is best to hold the selection in a collection and not rely on the checkbox alone. Then you can set the Default property of the checkbox to see if it is in the collection. You will need actions on the checkbox to remove and add records to the collection upon checking and unchecking the box.

 

There's a good example of this pattern in the App in a Day workshop for Device Orders (see the PDF for Module 1):

https://aka.ms/AppInADay

 

  1. Download the zip file.
  2. Open the zip file.
  3. Browse the contents of the zip to find "01-Power Apps Canvas App Lab Manual.pdf"
  4. The content on checkboxes starts around page 28.

Let me know if you were able to implement the checkbox behaviors.

View solution in original post

4 REPLIES 4
Power Apps
Power Apps

Hi @keihimekawa ,

It sounds like:

  • You have a gallery for making selections.
  • The gallery's items change as the text in the search box changes.

 

In a scenario involving selection of items, it is best to hold the selection in a collection and not rely on the checkbox alone. Then you can set the Default property of the checkbox to see if it is in the collection. You will need actions on the checkbox to remove and add records to the collection upon checking and unchecking the box.

 

There's a good example of this pattern in the App in a Day workshop for Device Orders (see the PDF for Module 1):

https://aka.ms/AppInADay

 

  1. Download the zip file.
  2. Open the zip file.
  3. Browse the contents of the zip to find "01-Power Apps Canvas App Lab Manual.pdf"
  4. The content on checkboxes starts around page 28.

Let me know if you were able to implement the checkbox behaviors.

View solution in original post

@Mr-Dang-MSFTyou are awesome! It worked! Thank you so much for sharing the "App in a day" workshop files!

Hi @Mr-Dang-MSFT - I added radio buttons on the gallery and a textbox wherein users can enter a comment if they selected "No".

Radioboxes also resets just like the checkbox before. Should I do a patch function on the collection for Selected items? I tried doing this but apparently, new items are added on the collection. Aplogies if I have too many questions. I'm still trying to familiarize my way around PowerApps.

Hi @keihimekawa ,

When a gallery's Items change due to it being filtered/searched, the values that have been typed or selected in its controls change as well. Those values are not saved anywhere. We use collections so that even if the gallery changes, the values in the collection remain the same.

 

You would be on the right track in using the Patch() function. If you are selecting a radio control and typing into a text box, you would set the OnChange property of the control to Patch the values to the respective columns in the collection.

 

Some caveats here: 

  • Is the gallery's Items property pointing to the same collection that you want to update?
    • If a gallery is set to a collection, and you make changes to that collection, the gallery may reload to reflect the changes.
    • If the gallery is set to another data source and you make changes to the collection, you won't be affected.
  • The OnChange property of the text input box will execute its actions (Patch in your case) even with changing one character. You might want to turn the DelayOutput property to true so that the actions don't execute until you press enter or leave the text input box.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (51,121)