Edit: Nevermind, fixed, sorry!
I have a table and a button. The button adds a row to the table when pressed. If the table has a row selected, it makes a copy of that row and inserts the copy below the selected one. If there is no row selected, it inserts a a blank row at the end.
Here’s the script on the button:
import system
data = event.source.parent.getComponent('ProcessTable').data
selectedRow = event.source.parent.getComponent('ProcessTable').selectedRow
#Create the new row. Copy the selected row if it exists, or create a new one
if selectedRow >= 0:
newRow = []
for i in range(data.columnCount):
newRow.append(data.getValueAt(selectedRow, i))
data = system.dataset.addRow(data, selectedRow, newRow)
else:
data = system.dataset.addRow(data, [None] * data.columnCount) #Array of length columnCount filled with Nones
#Update state numbers
for row in range(data.rowCount):
data = system.dataset.updateRow(data, row, {"state": row+1})
#Update the table
event.source.parent.getComponent('ProcessTable').data = data
event.source.parent.getComponent('ProcessTable').selectedRow = selectedRow+1
The copying/inserting works, but my problem is that when inserting a blank row with all None values, some columns display 0, and some display blank cells. Displaying 0 is desirable, but only for numerical columns. Any string columns should just be blank, so I can’t just insert 0 on all columns. The column attributes are identical for every column except a couple which have translation lists. Any idea why some columns are displaying something different than others if they all should have had None added?