# Adding row full of None values to table

**URL:** <https://forum.inductiveautomation.com/t/adding-row-full-of-none-values-to-table/3843>\
**Category:** Ignition\
**Created:** [January 10, 2012, 11:48pm UTC](https://forum.inductiveautomation.com/t/adding-row-full-of-none-values-to-table/3843 "2012-01-10T23:48:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![porksmash](https://avatars.discourse-cdn.com/v4/letter/p/848f3c/32.png) [@porksmash](https://forum.inductiveautomation.com/u/porksmash)\
**Post date:** [January 10, 2012, 11:48pm UTC](https://forum.inductiveautomation.com/t/adding-row-full-of-none-values-to-table/3843/1 "2012-01-10T23:48:33Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![porksmash](https://avatars.discourse-cdn.com/v4/letter/p/848f3c/32.png) [@porksmash](https://forum.inductiveautomation.com/u/porksmash)\
**Post date:** [January 11, 2012, 12:06am UTC](https://forum.inductiveautomation.com/t/adding-row-full-of-none-values-to-table/3843/2 "2012-01-11T00:06:10Z")

</div>

Cancel that, turns out that some columns were incorrectly typed as strings when they actually should have been doubles. Those incorrectly typed columns had been automatically added when I set the table’s data to a DB query result in another script. I couldn’t tell the column data types were wrong until I copied the dataset and pasted it into notepad.
