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

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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
Highlighted
Super User III
Super User III

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.

Highlighted
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

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.

Highlighted

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.

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

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)

Highlighted

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted

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.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,450)