I currently have a window that has some text fields that get submitted into a chart when i click submit. I can then double click on the row of the table and it will pull all the information back into the text fields. This is great, however, when I click submit with new data, it just creates a new row in the table.
I’m writing an ‘update’ script for a button for my table. I see that there is a function called updateRow and I was wondering if there was a simpler solution? If there is not a simpler solution, is it necessary that I convert my table to a Pydataset first or can I work with the raw values of my table?
I have tried changing a single cell using something like this:
but this always returns an error saying: SyntaxError: (“can’t assign to function call”, (", 11, 0, ‘data.getValue(selectedRows, “Action Item”) = string\n’))
The system.dataset.updateRow function is a simple solution.
Convert the row you want to change in the table into a list, modify the list and then create a new dataset with the changed row.
Example:
table = event.source.parent.getComponent("Table")
rowIndex = table.selectedRow
row = list(system.dataset.toPyDataSet(table.data)[rowIndex])
#change the row
row[2] = "new data"
row[0] = 10
#convert the row into a python dictionary
columns = list(table.data.getColumnNames())
row = dict(zip(columns,row))
#create a new dataset with the changed row and assign it to the table
table.data = system.dataset.updateRow(table.data, rowIndex, row)