# Question for Vision Dropdown List

**URL:** <https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895>\
**Category:** Ignition\
**Created:** [August 30, 2019, 5:10am UTC](https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895 "2019-08-30T05:10:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Min.Liao](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Min.Liao](https://forum.inductiveautomation.com/u/Min.Liao)\
**Post date:** [August 30, 2019, 5:10am UTC](https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895/1 "2019-08-30T05:10:57Z")

</div>

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](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/8efa071eb28effe1dbbbf4a78964d23a07b8b0de.png)  
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](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/cc09ecf784fbc822fe6e8a9228fb4f9de5ce752e.png)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 30, 2019, 8:56am UTC](https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895/2 "2019-08-30T08:56:56Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![Min.Liao](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Min.Liao](https://forum.inductiveautomation.com/u/Min.Liao)\
**Post date:** [August 30, 2019, 9:17am UTC](https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895/3 "2019-08-30T09:17:13Z")

</div>

Thanks for your help. It works very well.

---

<div class="post-metadata">

**Author:** ![Min.Liao](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Min.Liao](https://forum.inductiveautomation.com/u/Min.Liao)\
**Post date:** [September 2, 2019, 9:16am UTC](https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895/4 "2019-09-02T09:16:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 2, 2019, 10:16am UTC](https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895/5 "2019-09-02T10:16:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [September 2, 2019, 12:33pm UTC](https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895/6 "2019-09-02T12:33:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Min.Liao](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@Min.Liao](https://forum.inductiveautomation.com/u/Min.Liao)\
**Post date:** [September 3, 2019, 9:06am UTC](https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895/7 "2019-09-03T09:06:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andreia\_chiurato](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@andreia\_chiurato](https://forum.inductiveautomation.com/u/andreia_chiurato)\
**Post date:** [May 24, 2022, 6:22am UTC](https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895/8 "2022-05-24T06:22:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 24, 2022, 12:20pm UTC](https://forum.inductiveautomation.com/t/question-for-vision-dropdown-list/27895/9 "2022-05-24T12:20:17Z")

</div>

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.
