I am trying to add a row and data to a data set from a pop up window. The popup window has input fields intended to be the data for each column of the row. I am able to write a script the works in the same window, but I’d really like it to work with the pop-up. My table is a column of strings and a column of floats and is named “Heat_Draws”
First, here is my code that works in the same window via a button. There isn’t anything fancy and no binding for data entry.
table = event.source.parent.getComponent('Heat_Draws')
lastRow = table.data.rowCount
table.data = system.dataset.addRow(table.data, lastRow,['',0])
Now, when I try to move this to a pop-up, the first thing I did was bind the “Heat_Draws”.data to a custom property called “Temperatures” in the root container. Also, I am passing as a parameter the window path of the parent window (the one that has the “Heat_Draws” table) to the popup as a string called ‘CallingWindow’. The code ends up looking like this:
#Grab information from input fields on the popup
zone = event.source.parent.getComponent('Dropdown').selectedStringValue
setpoint = event.source.parent.getComponent('Setpoint Field').floatValue
#Using the CallingWindow parameter that was passed into the pop-up to get the Custom Property in the
#root contatiner of the parent window
window = system.gui.getWindow(event.source.parent.CallingWindow)
rootContainer = window.rootContainer
#Gets data set of table from parent window
dataSet = rootContainer.Temperatures
lastRow = dataSet.rowCount
#assign variable as new row data
newRow = [str(zone), setpoint]
#what I think is supposed to add the new row with the correct data
rootContainer.Temperatures = system.dataset.addRow(dataSet, lastRow, newRow)
system.nav.closeParentWindow(event)
I do not get any errors when trying this code in runtime or designer, but my datatable in the parent windows remains unchanged. When I use the print function in various places in the code, the output console shows information I would expect. It just seems the data doesn’t get back to the parent window.