Update two or more colums of a row in a table

Good day,

I have a text field that will have a string and i want to pass that string to an specific table, once a button is pressed. The script will section the string in two parts and will write each part in one specific column, but so far i can only write it in one column. My script is the following:

def ames_string(value):
parte = value[0:2]
ames = value[2:]
lista_ames = [ames,parte]
return lista_ames

value=event.source.parent.getComponent(‘Text Field’).text
tabla=event.source.parent.getComponent(‘Table’).data

string_parte = ames_string(value)

Los nombres de las columnas en lista

Columnas = system.dataset.getColumnHeaders(tabla)

col_ames = tabla.getColumnAsList(tabla.getColumnIndex(Columnas[0]))
col_parte =tabla.getColumnAsList(tabla.getColumnIndex(Columnas[1]))

col_ames.append(string_parte[0])
col_parte.append(string_parte[1])

col_1 = system.dataset.toDataSet([Columnas[0]], [ for x in col_ames])
col_2 = system.dataset.toDataSet([Columnas[0]], [[y] for y in col_ames])

event.source.parent.getComponent(‘Table’).data = col_1

In the last line i tried to add col_1,col_2 but it didnt worked.

Thank you for the support.
Regards

CMV

Consider using system.dataset.setValue - Ignition User Manual 8.1 - Ignition Documentation
or system.dataset.addRow - Ignition User Manual 8.1 - Ignition Documentation

Depending on if you’re updating an existing row or adding a new row

You mention updating, but it seems like you’re trying to add?

Thank you Matthew, it worked as i wanted. I appreciate the support and i wish you a great day.

Regards
CMV

1 Like

Glad you got it working!

Also, welcome to the forums :slight_smile: