cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
james_hathaway
Level: Powered On

Dropdown Control inside Gallery sometimes forgets selection

So, I have a Gallery showing a local Collection, where one of the fields is essentially a choice column. I have added a Dropdown Control into the Gallery Template, and have bound it to the appropriate column in the collection. I am using the "onChange" event of the Dropdown to Patch the record in the Local collection. (I already solved the issue with the dropDown.onChange event being fired every time the gallery is loaded, by setting a variable in the onSelect event - a trick I found on this forum somewhere)

 

Gallery.Items = local_Questions

Dropdown1.Items=["Yes","No"]

Dropdown1.Default=ThisItem.Answer

Dropdown1.onSelect = Set(dropdownChanged,true)

Dropdown1.onChange =

if(dropdownChanged,

     Patch(local_Questions,ThisItem,{Answer: Dropdown1.SelectedText}); Set(dropdownChanged,false)

,false)

 

This seems to work great about 80% of the time.

Unfortunately, about 20% of the time, there is a BUG where after selecting an answer in the Dropdown box, the control actually just clears and shows an emtpy value, and does not remember the Selection. Sometimes, it even clears the selected values from some of the other dropdowns in the gallery.

 

I can confirm that the onSelect and onChange events are firing correctly, but I can't figure out why it sometimes does NOT actually remember the User's selection.

I have also tried putting the "Patch" commanc into an external function (in a Timer) rather than patching directly from the onChange event of the control, as I thought that perhaps the onChange event is firing before the new selection has actually been registered, but this had no effect, and the random "clearing" of the drop-down still occurs.

 

Note, this happens in ALL browsers (Chrome, Firefox, IE and Edge). Interestingly, it does NOT occur in the Windows 10 PowerApps Desktop App (but as that desktop App is painfully slow at even clicking a button, it's not really a viable option for our Users). Also, the bug does NOT occur within the PowerApps studio - only once the app is saved, published, and run in a browser.

 

Does anyone have any bright ideas of why the dropdown control sometimes misbehaves?

And more importantly, what can I do to mitigate this anoying eroneous behaviour?

 

James.

1 ACCEPTED SOLUTION

Accepted Solutions
james_hathaway
Level: Powered On

Re: Dropdown Control inside Gallery sometimes forgets selection

Hi Kris,

 

Thanks for your reply, however I managed to solve the problem.

(Just FYI - I was alreay using your "dropdownChanged" methodology, and it wasn't that which was causing the issue...)

 

The problem was that old pesky bug with the Patch function and local Collections - i.e. that it will not let you Patch over a null value. So even though a value was selected, the Patch actually failed, so when it "reloaded" the value of ThisItem from the collection, it was still blank, so the control blanked out.

 

I solved the issues with the (anoying and severely performance inhibiting) workaround of

UpdateIf(local_Questions,isBlank(FIELD),{FIELD:""})

 

Thanks anyway!

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Dropdown Control inside Gallery sometimes forgets selection

Hi @james_hathaway ,

Could you please share a bit more about your issue?

Do you mean that the selection within the Dropdown box would sometimes be reset/clear?

Further, have you typed some Reset formula within your app?

 

Based on the issue that you mentioned, I have made a test on my side, and don't have the issue that you mentioned. Please consider modify your formula as below:

Set the OnSelect property of the Dropdown box to following:

Set(dropdownChanged, true)

set the OnChange property of the Dropdown box to following:

If(
   dropdownChanged = true,
   Patch(
          local_Questions,
          ThisItem,
          {
            Answer: Dropdown1.SelectedText.Value // or Dropdown1.Selected.Value
          }
   );Set(dropdownChanged, false)
)

Note: When specifying values for the Answer column in your collection, please type Dropdown1.SelectedText.Value rather than Dropdown1.SelectedText.

or

If(
   dropdownChanged = true,
   UpdateIf(
          local_Questions,
          PrimaryColumn = ThisItem.PrimaryColumn,
          {
            Answer: Dropdown1.SelectedText.Value // or Dropdown1.Selected.Value
          }
   );Set(dropdownChanged, false)
)

 

Please consider take a try with above solution, 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.
james_hathaway
Level: Powered On

Re: Dropdown Control inside Gallery sometimes forgets selection

Hi Kris,

 

Thanks for your reply, however I managed to solve the problem.

(Just FYI - I was alreay using your "dropdownChanged" methodology, and it wasn't that which was causing the issue...)

 

The problem was that old pesky bug with the Patch function and local Collections - i.e. that it will not let you Patch over a null value. So even though a value was selected, the Patch actually failed, so when it "reloaded" the value of ThisItem from the collection, it was still blank, so the control blanked out.

 

I solved the issues with the (anoying and severely performance inhibiting) workaround of

UpdateIf(local_Questions,isBlank(FIELD),{FIELD:""})

 

Thanks anyway!

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (6,177)