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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Radio buttons in galle...
Power Apps
Answered

Radio buttons in gallery keeps refreshing when typing something in "search" textbox

(0) ShareShare
ReportReport
Posted on by 99

Hi everyone.

I did an inquiry before regarding checkboxes here and @Mr-Dang-MSFT was so helpful in answering that out.

I'm now facing another dilemma. I added radio buttons on the gallery and a textbox wherein users can enter a comment if they selected "No" and now the Radio buttons and textboxes 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, the selected item does get updated but when I tried the searchbox, new items are added on the collection with blank radio button and textbox values.

I added my code on "OnSelect" part of the radiobutton. Am I doing it wrong?

Categories:
  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Hi @keihimekawa ,

    This is a known issue with “unbound” controls in a gallery. A workaround is to either add a field to the gallery data source reflecting the value of the radio button and patch to this, so when the gallery refreshes, it will show the value stored, or in the case of a yes/no control which is related to something in another field like the comments you mention, if the radio is yes when the comments are not blank, you could make the Default

    !IsBlank(YourCommentsFieldName)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    hi @keihimekawa ,

    Could you please share a screenshot about your Gallery's configuration?

     

    Based on the needs that you mentioned, I think this issue may be related to TextSearchBox. If you bind your Gallery with the TextSearchBox, when you type some search text or clear search text within the Search Box, the Gallery Items would be reset, So the previous selected Radio button and entered Comments value would be also be reset.

     

    As an fixed solution, you should save your selected Radio button value and entered comments value back to your data source using Patch function.

     

    I have made a test on my side, please consider take a try with the following workaround:

    Set the OnChange property of the Radio button inside your Gallery to following:

    Patch(
     'Your Data Source',
     LookUp('Your Data Source', PrimaryColumn = ThisItem.PrimaryColumn),
     {
     RadioColumn: Radio1.Radio1.Selected.Value
     }
    )

    Set the Default property of the Radio button to following:

    ThisItem.RadioColumn

     

    Set the OnChange property of the Comments Text Input Box inside your Gallery to following:

    Patch(
     'Your Data Source',
     LookUp('Your Data Source', PrimaryColumn = ThisItem.PrimaryColumn),
     {
     RadioColumn: Radio1.Radio1.Selected.Value,
     CommentsColumn: CommentsTextBox.Text
     }
    )

    Set the Default property of the Comments Text Input Box to following:

    ThisItem.CommentsColumn

    Note: The PrimaryColumn represents the Primary Column in your data source, which could identify one record uniquely. E.G. ID column in a SP List.

     

    Please consider take a try with above solution, then check if the issue is solved.

     

    Best regards,

  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Thanks @v-xida-msft for extrapolating on my suggestion.

    @keihimekawa I am happy to continue the conversation and suspect I may be online in your timezone.

  • keihimekawa Profile Picture
    99 on at

    Thank you @WarrenBelz , @v-xida-msft . I'll try your suggestion and will get back to you if I was able to make this work.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @keihimekawa ,

    Sure, please take a try with the solution I provided, check if it could help in your scenario.

     

    If you have any issue with the formula, please feel free to let me know here.

     

    Best regards,

  • keihimekawa Profile Picture
    99 on at

    Hi @v-xida-msft - tried your solution and I'm having some issues. I'm sure I'm doing something wrong but I can't pinpoint where exactly. Let me explain:

    1. I have a checkbox (chkBox) applied on each gallery item. On "check", the radio button will then appear.
      • Under the "OnCheck" action, I have a rule which collects the selected item and places it in another collection (SelectedItems).
      • The checkbox's default is set to "ThisItem in SelectedItems"
      • When I type in something in the search textbox, the checkbox value did not refreshes
      • This works
    2. I tried applying the "Patch" rule on the radiobuttons and patched my gallery's collection datasource (collectMainDatasource)
      • Patch takes some time to complete. Probably because collectMainDatasource holds 20k+ items
      • Once patch completes, chkBox becomes unticked. When I ticked it once more, radiobutton is populated

    Question: Do I need to take a different route and patch "SelectedItems" collections instead? I can send you my gallery's actual code (but it's pretty lengthy)

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @keihimekawa ,

    Do you add a Checkbox control inside your Gallery to control the visible of the Radio button control?

    Do you mean that the chkBox becomes unticked once you execute your Patch formula?

     

    Based on the issue that you mentioned, I think there is something wrong with the selected item collected in your SelectedItems collection.

     

    I assume that you use the following formula to collect the selected item in your SelectedItems collection:

    Collect(SelectedItems, ThisItem)

    is it true?

     

    If you use above formula to collect the selected item in your Gallery, I think your issue is related to it. If you execute the Patch formula via the OnChange property of the Radio button, the corresponding item would be updated (e.g. RadioColumn would be populated with proper value). But the selected item stored in your SelectedItems collection has not been updated, so the ThisItem in SelectedItems formula would return false in your Gallery.

     

    As an alternative solution, I think it is not necessary to collect the whole item record into your SelectedItems collection, instead, you could collect the Primary Key column value of each selected item into the SelectedItems collection, I assume that the Primary Key column value of each Gallery Item would not be changed.

    Please take a try with the following workaround:

    Set the OnCheck property of the Checkbox (chkBox) to following:

    Collect(SelectedItemsKey, ThisItem.PrimaryKeyColumn)

    set the OnUncheck property of the Checkbox (chkBox) to following:

    RemoveIf(SelectedItemsKey, Value = ThisItem.PrimaryKeyColumn)

    set the Default property of the chkBox to following:

    ThisItem.PrimaryKeyColumn in SelectedItemsKey

     

    Please take a try with above solution, then check if the issue is solved.

     

    Best regards,

  • keihimekawa Profile Picture
    99 on at

    Hi @v-xida-msft

    to answer your question:

    • Do you add a Checkbox control inside your Gallery to control the visible of the Radio button control?
      Yes
    • Do you mean that the chkBox becomes unticked once you execute your Patch formula?
      Yes
    • I assume that you use the following formula to collect the selected item in your SelectedItems collection - is it true?
      Yes

    Thank you so much for the assistance. I was able to make it work. With your codes, explanations and advises, it worked 🎉 Instead of patching the collection I'm using as datasource for my gallery, I created a new collection and saved the radio button selection and textbox content into it. I then played around with the new collection and everything fell into place.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard