Change a single value of a cell with a script

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? :question: 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:

data.getValue(selectedRows, “Action Item”) = string

but this always returns an error saying: SyntaxError: (“can’t assign to function call”, (", 11, 0, ‘data.getValue(selectedRows, “Action Item”) = string\n’))

Thanks in Advance for the help! :thumb_left:

Hi alewayhar,

See the documentation for the system.dataset.setValue function.

Here is the example the documentation gives:

table = event.source.parent.getComponent("Table")
selRow = table.getSelectedRow()
selCol = table.getSelectedColumn()
if selRow != -1 and selCol != -1:
   newData = system.dataset.setValue(, selRow, selCol, 0.0) = newData

Do you know if this is possible to do just for the entire row? Not just changing a single cell, but expanding it to change the entire row?

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.


table = event.source.parent.getComponent("Table") rowIndex = table.selectedRow row = list(system.dataset.toPyDataSet([rowIndex]) #change the row row[2] = "new data" row[0] = 10 #convert the row into a python dictionary columns = list( row = dict(zip(columns,row)) #create a new dataset with the changed row and assign it to the table = system.dataset.updateRow(, rowIndex, row)

system.dataset.updateRow() will do that for you.

[code]selRow = table.getSelectedRow()
if selRow != -1:
dataIn = event.source.parent.getComponent(“Table”).data
point1 = event.source.parent.getComponent(“TextBox1”).text
point1 = event.source.parent.getComponent(“TextBox2”).text
point1 = event.source.parent.getComponent(“TextBox3”).text

updates = {“colName1” : point1, “colName2” : point2, “colName3” : point3}

dataOut = system.dataset.updateRow(dataIn, selRow, updates)

EDIT Nick beat me to it! :wink: