# Accessing data from a dropdown menu instantiated as an embedded view in a table

**URL:** <https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 28, 2021, 1:46pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301 "2021-07-28T13:46:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![erik.knoetze](https://avatars.discourse-cdn.com/v4/letter/e/8edcca/32.png) [@erik.knoetze](https://forum.inductiveautomation.com/u/erik.knoetze)\
**Post date:** [July 28, 2021, 1:46pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/1 "2021-07-28T13:46:36Z")

</div>

I have a table with three columns, the first two hold identifier values and the third holds a dropdown menu instantiated automatically for each entry. The data for the first two columns is read from a database.

Currently the dropdown menus are identified when selected and the database is queried using the getSelectedIndex function of the table to get data into the dropdowns.

How should I go about supplying the other table data to the dropdowns when they are initiated rather than waiting for a user to select a data row?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 28, 2021, 2:03pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/2 "2021-07-28T14:03:51Z")

</div>

Where you create the dropdown? Why do you not fill it up immediately?

---

<div class="post-metadata">

**Author:** ![erik.knoetze](https://avatars.discourse-cdn.com/v4/letter/e/8edcca/32.png) [@erik.knoetze](https://forum.inductiveautomation.com/u/erik.knoetze)\
**Post date:** [July 28, 2021, 2:07pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/3 "2021-07-28T14:07:11Z")

</div>

The dropdown is created as an embedded view by calling the view path in the columns section of the table properties and I am unable to create them on a entry-by-entry basis.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 28, 2021, 2:08pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/4 "2021-07-28T14:08:51Z")

</div>

So, you could give parameters aswell to the view which then fills up the dropdown?

---

<div class="post-metadata">

**Author:** ![erik.knoetze](https://avatars.discourse-cdn.com/v4/letter/e/8edcca/32.png) [@erik.knoetze](https://forum.inductiveautomation.com/u/erik.knoetze)\
**Post date:** [July 28, 2021, 2:14pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/5 "2021-07-28T14:14:09Z")

</div>

Yes, I am trying to send parameters through the view, but the parameters need to be from the same row in the other columns and I can only retrieve them from the the database after all the components are already created, by finding the correct row value that the dropdown is in using selectedRow

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 28, 2021, 2:19pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/6 "2021-07-28T14:19:49Z")

</div>

heh i see.  
could you show me how you are filling them up right now?

---

<div class="post-metadata">

**Author:** ![erik.knoetze](https://avatars.discourse-cdn.com/v4/letter/e/8edcca/32.png) [@erik.knoetze](https://forum.inductiveautomation.com/u/erik.knoetze)\
**Post date:** [July 28, 2021, 2:24pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/7 "2021-07-28T14:24:42Z")

</div>

Right now they are filled with a static list that’s hardcoded into the dropdown. I also have a changeScript that reads the chosen dropdown item and then pulls new parameters to use from the selected row.

Thank you for your help, I appreciate it

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 28, 2021, 2:28pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/8 "2021-07-28T14:28:51Z")

</div>

could you show me that changescript?^^

---

<div class="post-metadata">

**Author:** ![erik.knoetze](https://avatars.discourse-cdn.com/v4/letter/e/8edcca/32.png) [@erik.knoetze](https://forum.inductiveautomation.com/u/erik.knoetze)\
**Post date:** [July 28, 2021, 2:30pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/9 "2021-07-28T14:30:01Z")

</div>

def valueChanged(self, previousValue, currentValue, origin, missedEvents):  
“”"  
This function will be called when the value of the property changes.

```
Arguments:
	self: A reference to the component that is invoking this function.
	previousValue: The previous value, as a qualified value object.
	currentValue: The new value, as a qualified value object.
	origin: The origin of the property value. Possible origin values include
	        Browser, Binding, BindingWriteback, Script, Delegate, Session, Project
	missedEvents: A flag indicating that some events have been skipped due
	              to event overflow.
"""

id = self.view.params.id
colName = self.view.params.colName

if id != "NoId":
	if colName != "NoId":
		update = "UPDATE destination SET chuteID = ? WHERE " + colName + " = ? "
		p = [self.props.value,id]
		r = system.db.runPrepUpdate(update,p)
```

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 28, 2021, 2:34pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/10 "2021-07-28T14:34:40Z")

</div>

You are writing down the dropdowns options in the database when they click a row?

Thats not neccecary!  
in your view with the dropdown you can add the params (or just the ones you need):

```auto
column
columnIndex
row
rowIndex
value
rowData

```

These will get automattically filled in to each row correctly, no need to bind it in the viewParams either!

Here i just use a textfield and label but you see what i mean?^^

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/b/9b2cd9cf49703cc49452d37a4c8d5b7b1ec692bd.png)  
(viewpaths name is just ‘text’ xd made a quick example)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/7/1706a309fe4975fb8ea6a6b6ab0f02a8e00d9008.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cf917fa510beb065e84c92cdcb7584a094ae0fda.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/1/b18429b0f2d8fb658e0a2da537814e0a21985981.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/b/8bbc0da53042d892fcf408ad44bcf2a74f30001f.png)

---

<div class="post-metadata">

**Author:** ![erik.knoetze](https://avatars.discourse-cdn.com/v4/letter/e/8edcca/32.png) [@erik.knoetze](https://forum.inductiveautomation.com/u/erik.knoetze)\
**Post date:** [July 28, 2021, 3:26pm UTC](https://forum.inductiveautomation.com/t/accessing-data-from-a-dropdown-menu-instantiated-as-an-embedded-view-in-a-table/49301/11 "2021-07-28T15:26:57Z")

</div>

Thank you so much!
