# Table How To

**URL:** <https://forum.inductiveautomation.com/t/table-how-to/5454>\
**Category:** Ignition\
**Created:** [November 20, 2012, 5:25pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454 "2012-11-20T17:25:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [November 20, 2012, 5:25pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454/1 "2012-11-20T17:25:56Z")

</div>

Hi, how do i tell a tag value to be inserted to the table?  
i have a dropdown list where example the value “Test” is selected, what i want to happen is when that value is selected from the drop down, the value of the tag will be inserted to the first row in the table, how do i do that?

I saw that there is a setValue in the manual i think that’s what i need but how do i use it?

thanks in advance

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [November 20, 2012, 5:39pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454/2 "2012-11-20T17:39:49Z")

</div>

You’ll need to put a script on the propertyChange event handler of the dropdown, and then verify that the correct property is changing:

```auto
if event.propertyName == "selectedValue":
```

You can then use addRow() on a table instance:

```auto
event.source.parent.getComponent("Table").addRow([])
```

You would put the dataset of values (comma separated) inside the brackets. Make sure that the number of values equal the number of columns in the table, and that the values can be coerced to the column datatype.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [November 20, 2012, 6:16pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454/3 "2012-11-20T18:16:11Z")

</div>

EDIT: It looks like the post I was replying to was deleted, but I’ll leave my response here if others were curious about why the propertyChange event handler was used.

The propertyChange event only executes when a property of a given component has changed. Specifically, you’re interested in the “selectedValue” property of the dropdown, right? Adding that line of code I referenced earlier will ensure the propertyChange event fires only if the selectedValue of the dropdown is changed, and then that selected value gets added to the table.

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [November 20, 2012, 6:38pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454/4 "2012-11-20T18:38:16Z")

</div>

Ok, so i don’t know if I did this correctly.  
I entered this in the property change event of the dropdown  
if event.propertyName == “selectedValue”:  
event.source.parent.getComponent(“Table 1”).addRow([0,2,“05A FIT”])

and then inserted this on the mouse click event  
table = event.source.parent.getComponent(“Table 1”)  
dropdown = event.source.selectedValue  
if dropdown == “OU2-11-A”:  
table = setValue(2,2,“05A FIT”)

the value of the tag (05A FIT) wasn’t added to the value, what did i do wrong? i kind of just started using ignition and python, i’m really sorry about all this questions

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [November 20, 2012, 7:10pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454/5 "2012-11-20T19:10:11Z")

</div>

You’re on the right track with the propertyChange, but don’t worry about mouseClicked, you’re only concerned about when the value of the dropdown box changes. So you’ll first check to see if the property that changed is the right property, then you’ll check to see if the changed property is a specific string, and then add the value to the table. Also, to pull in a tag value in scripting, you have to use system.tag.read().value. So your propertyChange script looks like this:

`if event.propertyName == "selectedLabel":
	if event.source.selectedLabel == "tag":
		event.source.parent.getComponent("Table").addRow([1, system.tag.read("tagpath").value])`

You can interchange selectedLabel with selectedValue, depending on how you structured your dropdown box dataset.

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [November 20, 2012, 8:14pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454/6 "2012-11-20T20:14:13Z")

</div>

Ok so i tried that code and pasted it on the propertychange event and changed the other details like the tag, tagpath and table name and I got this error (errordetails.jpg) so what did was i tried to do it like this just

`if event.propertyName == "selectedLabel":
	if event.source.selectedLabel == "tag":
		tag = system.tag.read("tagpath")
		event.source.parent.getComponent("Table").addRow([1, tag.value])`

but i’m still having that error saying that there’s no ‘read’ attribute

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/b/bb360d3b34238fe9c8b3a8edfe0116523c351e57.JPG)

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [November 20, 2012, 8:23pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454/7 "2012-11-20T20:23:12Z")

</div>

Since you’re using 7.3.8 you’ll want to use system.tag.getTagValue() instead of system.tag.read().value. The read() function was added in 7.5.

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [November 20, 2012, 8:49pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454/8 "2012-11-20T20:49:41Z")

</div>

Finally! It worked. ![:prayer:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e5a7e3b63facc151ea73e3b45db7bdb3d4bdc316.gif ":prayer:")

Last one though, I kind of already have the tables layout, 5 columns and 10 rows. I don’t want it to add rows just insert it to the rows and columns that are already there, what should i use instead of addrow?

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [November 20, 2012, 9:02pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454/9 "2012-11-20T21:02:51Z")

</div>

In that case you’ll want to use updateRow, which takes two parameters: the row index, and a PyDictionary of column names/indices and new values. Here’s an example of editing the third row of a table with columns “a” and “b” with values 23 and 24:

```auto
event.source.parent.getComponent("Table").updateRow(2,{"a":23,"b":24})
```

or

```auto
event.source.parent.getComponent("Table").updateRow(2,{0:23,1:24})
```

---

<div class="post-metadata">

**Author:** ![cacordova](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@cacordova](https://forum.inductiveautomation.com/u/cacordova)\
**Post date:** [November 20, 2012, 9:15pm UTC](https://forum.inductiveautomation.com/t/table-how-to/5454/10 "2012-11-20T21:15:42Z")

</div>

I got it now.

Thanks for all the help! ![:prayer:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e5a7e3b63facc151ea73e3b45db7bdb3d4bdc316.gif ":prayer:") ![:thumb_right:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/2026e28c0c425034352c1b75807edf956adc75f4.gif ":thumb\_right:")😃
