# Ignition 7.9 Table Dynamic Dropdown List on String Column

**URL:** <https://forum.inductiveautomation.com/t/ignition-7-9-table-dynamic-dropdown-list-on-string-column/14299>\
**Category:** Ignition\
**Created:** [May 15, 2017, 2:44pm UTC](https://forum.inductiveautomation.com/t/ignition-7-9-table-dynamic-dropdown-list-on-string-column/14299 "2017-05-15T14:44:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 15, 2017, 2:44pm UTC](https://forum.inductiveautomation.com/t/ignition-7-9-table-dynamic-dropdown-list-on-string-column/14299/1 "2017-05-15T14:44:08Z")

</div>

I am using the following code to attempt to populate the translation Map of a table. Using this combined with a cell update binding should allow for a dynamic drop down list in the cell.

The problem I am having is that the code works for two of the columns but the third for whatever reason just doesn’t seem to take. I separated the code for the translateStep property to insure that I was doing everything the same way. Doesn’t seem to matter what I do though, the mapping just doesn’t show up for that column. I have attached a couple screen shots to show the cell binding and the table customizer. As you can see there is a value in the translateMap for the Step Code column but the table customizer shows no mappings.

I have tried manually checking the “Use Translation List” check box but still no dice.

Any help is appreciated.

```auto
if event.propertyName == 'translateItem':
	
	tIStr = '<list>'
	tUStr = '<list>'
	
	ds = event.source.translateItem
	
	for row in range(ds.rowCount):
		if str(ds.getValueAt(row,1)) <> 'None':
			tIStr = tIStr + '<stringpair><key>' + str(ds.getValueAt(row,0)) + '</key><value>' + ds.getValueAt(row,1) + '</value></stringpair>'
			tUStr = tUStr + '<stringpair><key>' + str(ds.getValueAt(row,0)) + '</key><value>' + ds.getValueAt(row,2) + '</value></stringpair>'
	tIStr = tIStr + '</list>'
	tUStr = tUStr + '</list>'
	
	event.source.translateItemStr = tIStr
	event.source.translateUnitStr = tUStr
	
elif event.propertyName == 'translateStep':
	
	tSStr = '<list>'
	
	ds = event.source.translateStep
	
	for row in range(ds.rowCount):
		tSStr = tSStr + '<stringpaiir><key>' + str(ds.getValueAt(row,0)) + '</key><value>' + ds.getValueAt(row,1) + '</value></stringpair>'
		
	tSStr = tSStr + '</list>'
	
	event.source.translateStepStr = tSStr

```

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/d326e08eab889c373d1e87593f6980fa6127a8da.png)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 15, 2017, 5:30pm UTC](https://forum.inductiveautomation.com/t/ignition-7-9-table-dynamic-dropdown-list-on-string-column/14299/2 "2017-05-15T17:30:07Z")

</div>

After some further digging, and correcting the incorrect spelling of ‘stringpair’ in my original code, it turns out that the real issue is that the underlying data in my values is not ‘HTML Safe’ meaning that it doesn’t properly escape special characters.

Now I am just looking for an easy way to do that.

Any help is still appreciated.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 15, 2017, 6:03pm UTC](https://forum.inductiveautomation.com/t/ignition-7-9-table-dynamic-dropdown-list-on-string-column/14299/3 "2017-05-15T18:03:23Z")

</div>

Final working script for any who happens upon this post and might have the same issue.

It’s important that what ever string you put into the translateMap for the column be valid HTML. I used the str.replace() method to do this, but I’m not sure if there is possibly another method that is more comprehensive than this. For instance I have not accounted for any special character other than the ‘&’ in this code.

```auto
if event.propertyName == 'translateItem':
	
	tIStr = '<list>'
	tUStr = '<list>'
	tSStr = '<list>'
	
	ds = event.source.translateItem
	
	for row in range(ds.rowCount):
		if str(ds.getValueAt(row,1)) == 'None':
			tIStr = tIStr + '<stringpair><key>' + str(ds.getValueAt(row,0)) + '</key><value></value></stringpair>'
		else:
			tIStr = tIStr + '<stringpair><key>' + str(ds.getValueAt(row,0)) + '</key><value>' + ds.getValueAt(row,1) + '</value></stringpair>'
		
		tUStr = tUStr + '<stringpair><key>' + str(ds.getValueAt(row,0)) + '</key><value>' + ds.getValueAt(row,2) + '</value></stringpair>'
		tSStr = tSStr + '<stringpair><key>' + str(ds.getValueAt(row,0)) + '</key><value>' + ds.getValueAt(row,3).replace('&','&amp;') + '</value></stringpair>'
					
	tIStr = tIStr + '</list>'
	tUStr = tUStr + '</list>'
	tSStr = tSStr + '</list>'
	
	event.source.translateItemStr = tIStr
	event.source.translateUnitStr = tUStr
	event.source.translateStepStr = tSStr

```

---

<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 15, 2017, 8:29pm UTC](https://forum.inductiveautomation.com/t/ignition-7-9-table-dynamic-dropdown-list-on-string-column/14299/4 "2017-05-15T20:29:06Z")

</div>

Ignition includes the Apache Commons Lang3 library, which has [StringEscapeUtils.escapeHtml4()](https://commons.apache.org/proper/commons-lang/javadocs/api-3.4/org/apache/commons/lang3/StringEscapeUtils.html#escapeHtml4(java.lang.String)) available. Use it like so:

```auto
from org.apache.commons.lang3 import StringEscapeUtils
...
tSStr = tSStr + '<stringpair><key>' + str(ds.getValueAt(row,0)) + '</key><value>' + StringEscapeUtils.escapeHtml4(ds.getValueAt(row,3)) + '</value></stringpair>'

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 15, 2017, 8:45pm UTC](https://forum.inductiveautomation.com/t/ignition-7-9-table-dynamic-dropdown-list-on-string-column/14299/5 "2017-05-15T20:45:28Z")

</div>

The Python standard library’s [urllib](https://docs.python.org/2/library/urllib.html#utility-functions) is also a good choice for this, with the quote() and quote\_plus() functions.
