Hey so I’m having a little trouble using code to fill in tables on different windows.
I have a filled in data table on my main window and I am trying to get the scripting to work so that when I select multiple rows in the Table and then press a button, it copy’s those selected rows to a table in a new window.
Here is the Script I have written. It doesn’t throw an error but it doesn’t fill in the Table on window “T1”
event.source.parent.getComponent('Table').data = dataOut
#selected rows I want to Copy
T1Data = dataOut.selectedRows
#header of Table copy
Headers = system.dataset.getColumnHeaders("Table").text
New = system.dataset.toDataset(Header, T1Data)
system.gui.getwindow("T1").rootContainer.getComponent("TableT1").data = New
any suggestions?
agweb.salinas
You might try a different way.
Make a custom property on the page as a dataset and have it be the same as your “New” dataset,
Make your page open button pass this custom property to a similar custom property on the new page and populate the new table from that.
1 Like
Your code is not doing anything because your syntax is wrong in a variety of ways.
First:
event.source.parent.getComponent('Table').data = dataOut
Is assigning the table’s data property to the (nonexistent) dataOut
variable, not creating a new variable dataOut
.
#selected rows I want to Copy
T1Data = dataOut.selectedRows
#header of Table copy
Headers = system.dataset.getColumnHeaders("Table").text
New = system.dataset.toDataset(Header, T1Data)
This isn’t doing what you want, either. system.dataset.toDataSet
(remember capitalization is important) requires a sequence of column names, and a sequence of sequences, each of which must be as long as the header list. You can visualize the required structure like this (using python’s list notation)
["Header 1", "Header 2", "Header 3"]`
[
[row1col1, row1col2, row1col3],
[row2col1, row2col2, row2col3]
]
@Chris_Taylor’s suggestion is definitely valid, but if you specifically want to do this with a script then you need to take the selected rows property and combine it with system.dataset.deleteRows
:
sourceTable = event.source.parent.getComponent('Table')
dataOut = sourceTable.data
selectedRows = sourceTable.selectedRows
system.gui.getWindow("T1").rootContainer.getComponent("TableT1").data = system.dataset.deleteRows(dataOut, selectedRows)
1 Like
Ah I see. I was making the assumption that if you say :
New = system.dataset.toDataSet(Header, T1Data) (with correct structure)
system.gui.getwindow(“T1”).rootContainer.getComponent(“TableT1”).data = New
then you could manipulate it in reverse.
Is there a command for identifying the unselected rows? I would like the selected rows to appear in the new table rather than selecting all the rows I don’t want. perhaps like an appendRow method?