Question for Vision Dropdown List

Hi,
I used a dropdown list in a template. But once I selected one in a window, the selection would keep in any window I opened using this template. I searched on the forum, the suggestion was that we can set the selectedIndex of this component. But where I can write this code using python script.
Each window I opened would keep my last selection, the screen was as below:
image
In my experience of web development, I never met such question, my question is that how to display the first row not my selection on other window when I open a window.Below is my expected affect.
image

Edit: I’m assuming you’re talking about Vision since you mentioned you made it in a Template.

Not sure what you plan to do with this component, but usually you would bidirectionally bind one of the selected properties (selectedIndex or selectedLabel) to a tag.
If you don’t want to bind it but want it to reset, you can set the selectedIndex property by executing a script on the component’s property change event handler, specifically on change of its ‘componentRunning’ property.

If event.propertyName == 'componentRunning':
     event.source.selectedIndex = 0

Thanks for your help. It works very well.

Hi , Nminchin
I define a dataset which gets selection items from a database,but it often throws an exception of "0 out of bounds’.I guess that’s because the dataset is null before the script executes.Do you know why this happens and how I can solve this issue?

Hmm, what if you change the if condition to use data instead of componentRunning?

or wrap it in try: ... except: ... to just ignore the error

1 Like

Thank you all. Now, I adopted Sanderd17’s suggestion to solve the problem.

Hi,

I have a similar problem. I created a template with dropdown list ( but I have other properties binding in Data and SelectedValue, that I need to show some options), and I note that when I close the gateway (for now is Trial version) or restart de computer, the values don’t remain with the last choice, return to ** < SelectOne > **
I tried create a custom property to write this value …exist one way to fixed the last choice?
Thanks.
Vision version 8.1

Properties are not persistent outside the client session. To make something persistent, bind to a gateway memory tag. Note that this also makes it shared for all clients. If you need individual persistence, you will need to construct something custom with a database, keyed by user.

1 Like