cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
iwonder
Impactful Individual
Impactful Individual

Reset Drop Down when leaving screen

Thank you for taking the time to read my question.

I have this code that resets my drop down.

 

UpdateContext({resettext: !resettext});
UpdateContext({resettext: !resettext});

 

It currently runs when the screen becomes visible (OnVisible). The drop down filters a gallery. 

 

I want to reset my drop down because it remembers what I selected last time I was on that screen and filters for that value. Having the code run at OnVisible flashes the gallery for a second before the drop down is reset. I don't want this...

 

I have a back button and I put my code on that button before the Back() function is called. That does not seem to reset the drop down. 

 

How can I reset my drop down before the user navigates to the screen so they do not see a flash of what was selected last time before resetting?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
iwonder
Impactful Individual
Impactful Individual

I believe I have it.

 

The Items() of my drop down is now:

 

Distinct(Sort(colPlants,Result),Result)

 

and I use Reset() before leaving the screen.

 

Thanks!

View solution in original post

8 REPLIES 8
Pstork1
Dual Super User
Dual Super User

Instead of resetting the value using a context variable simply call on the button.

reset(dropdowncontrolname);

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
iwonder
Impactful Individual
Impactful Individual

Hi @Pstork1 

 

Thank you for your quick reply.

 

Here is what I have now:

Reset(ddFilterPlant);
Navigate(CustomerScreen,Fade)
//Back(ScreenTransition.Fade);

 

checking to see if Navigate acts any differently....

 

When I go back to the CustomerScreen, then navigate back to the FilterScreen (where the drop down is) the previously selected value in ddFilterPlant is still remembered.

 

 

What is the default setting for ddFilterPlant?  Doing a Reset should set the dropdown back to the original default value.  Do you still have the code in the OnVisible?  Taht may be overriding the default when you navigate back to the screen.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
iwonder
Impactful Individual
Impactful Individual

I did not have a default value for my drop down. I've set it to

"*SELECT"

 

Tried again and it still remembers the value I selected before leaving the screen.


The Items for my drop down come from a collection:

Sort(colPlants,Result)

I make the collection by ClearCollect a distinct list from a SharePoint list and then I Collect "*SELECT" to the collection

 

any other thoughts?

iwonder
Impactful Individual
Impactful Individual

Did more testing... it seems it always selects the second value in the list unless I use my original code in the OnView of the screen. So even if I select the 4th value in the list, when I come back it sets it to the second value in the list.

 

Not sure if that helps.

iwonder
Impactful Individual
Impactful Individual

I added a temporary button to my screen and the Reset() works as expected. I just does not seem to work if I place it on my icon which is used to navigate back to the CustomerScreen.

 

Also, if I set my drop down to *Select, I do not get that value when I return to the page.

 

It must not have anything to do with the Reset() function but perhaps a setting on my drop down?

iwonder
Impactful Individual
Impactful Individual

Sorry for all the posts....

 

Originally if I entered the app for the first time the drop down would default to the first value... now that I've been playing with my app, it no longer does that. I deleted the drop down and added a new one... it still does not select the first value in the list

iwonder
Impactful Individual
Impactful Individual

I believe I have it.

 

The Items() of my drop down is now:

 

Distinct(Sort(colPlants,Result),Result)

 

and I use Reset() before leaving the screen.

 

Thanks!

Helpful resources

Top Solution Authors
Top Kudoed Authors
Users online (4,063)