Dropdown pre select

Hello,
I have 3 dropdown like this:


I would like to pre-select them by script at start up.
Trying to write to returnValue didn't work.
Does anyone have an idea?
Thanks.

Show us the binding between the dropdown and the view params.returnValue.

Thank you for your quick reply. I do not have binding, I just have tried to write from start up script "workshop A" by exemple and check if it indicate "workshop A" instead of "Select" on the dropdown main line. But it may not be the best way for pre-selection on opening view ...

To programmatically select an option you set the value to the option you want.

View parameters are read once at startup.

  • Create a property binding on value and point it at view.params.returnValue (which you should have added to the dropdown view).
  • You may want to set the binding as bidirectional if you want to read it back from the main view.
  • Then feed the value you want into params.returnValue on your embedded view.

I'd advise against putting startup scripts everywhere. Bindings are, most of the time, the way to go.

In your example:
Make returnValue bidirectional.
Then bind the dropdown's value to that parameter. Make this binding bidirectional.

Note: In this situation, I like having an input parameter, binding the dropdown to it, then an output parameter, bound to the dropdown.

Just wondering, what's the difference between that and making the parameter an Input/Output?

You can process the input before displaying it, which you can't do with a bidirectional binding.
And you can restore the initial value with a simple refreshBinding.
It also allows for a comparison between input and output, so you can for example extract only the ones that changed. Can be useful if you need to write them somewhere, you don't have to write the whole thing.

1 Like

Thank you very much Transistor, Pascal I keep in mind your suggestion thank you too.