Filling in Table Dataset From Left to Right, Insert New Row

I have a manually created dataset in a table. It has a dynamic number of columns, and starts with one empty row. I have a button that should log a time value when pressed. The time should be appended to the table’s dataset with each button press from left to right, then when the row is completed it should insert another blank row and continue the process. The number of table columns does not change during the time logging process. I’m unsure on how to go about this. Thanks

You could create a custom property on the table to server as a pointer to which column you should write to next, then on button press compare the pointer value to the number of columns in the table using getColumnCount. If the pointer is still less than the total column count, update that value, if not then create a new row and reset the pointer.

Okay, I will see if I can implement your logic. Thanks

1 Like

Superb suggestion, I got it to work exactly how I wanted. Thanks for the reply

time = event.source.parent.getComponent('LED Display').value
currentData = event.source.parent.getComponent('Power Table').data
rowIndex = event.source.parent.getComponent('Power Table').rowRef 
colIndex = event.source.parent.getComponent('Power Table').colRef
colCount = currentData.getColumnCount()

newData = system.dataset.setValue(currentData, rowIndex, colIndex, time)
colIndex = colIndex +1
event.source.parent.getComponent('Power Table').colRef = colIndex

if colCount == colIndex:
	rowIndex = rowIndex + 1
	newRow = []
	for i in range(colCount):
		newRow.append('')
	newData = system.dataset.addRow(newData,newRow)
	event.source.parent.getComponent('Power Table').colRef = 0
	event.source.parent.getComponent('Power Table').rowRef = rowIndex 
	
system.tag.write("[Client]RegularElements", newData)
1 Like