I have a dropdown with a list where the user can select an item.
Then when I change screens I want the dropdown to start with the item that was selected.
How can I do this?
Hi Sérgio,
If I understand your question, you select an option in the dropdown, then you leave the screen. When you return to that screen from another screen, you want the option that you had selected there to still be there, is that right?
For this, you can create a Client Variable and put that client variable as the variable of your dropdown. This variable will store that information client side throughout your session.
Let me know if this helped!
Cheers,
Paulo
Hello Sergio,
Can you please provide some additional clarification (for example, screen a, screen b, and then back to screen a)? Will the selected option remain unchanged? (Is it like this?) or the demo OML so we will help you ASAP
Edit: If I am getting you right I have attached the OML and DEMO(if you have two screen you can go with the input parameter and if you have more than two screen better to go with client property because its scope for all application and not only for some screen)
I hope this will help you...Thanks and Regards,Akshay Deshpande
You can use the SetSelectedIndex action of the Dropdown widget to set the selected item in the dropdown. This action takes one argument: the index of the item that you want to select.
Here is an example of how to use the SetSelectedIndex action to set the selected item in a Dropdown widget:
// get the index of the item that was selected by the user
var selectedIndex = Dropdown1.SelectedIndex;
// navigate to the next screen
NavigateToScreen("NextScreen");
// set the selected item in the Dropdown widget on the next screen
Dropdown1.SetSelectedIndex(selectedIndex);
In the code above, we first get the index of the selected item in the Dropdown widget using the SelectedIndex property. We then navigate to the next screen using the NavigateToScreen action. On the next screen, we use the SetSelectedIndex action to set the selected item in the Dropdown widget using the value of the selectedIndex variable.
You can use this approach to preserve the selected item in a Dropdown widget when navigating between screens in OutSystems.