# Writing in Tables on Other Windows

**URL:** <https://forum.inductiveautomation.com/t/writing-in-tables-on-other-windows/19455>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [August 29, 2018, 6:54pm UTC](https://forum.inductiveautomation.com/t/writing-in-tables-on-other-windows/19455 "2018-08-29T18:54:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![agweb.salinas](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@agweb.salinas](https://forum.inductiveautomation.com/u/agweb.salinas)\
**Post date:** [August 29, 2018, 6:54pm UTC](https://forum.inductiveautomation.com/t/writing-in-tables-on-other-windows/19455/1 "2018-08-29T18:54:30Z")

</div>

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”

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

---

<div class="post-metadata">

**Author:** ![Chris\_Taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chris_taylor/32/3315_2.png) [@Chris\_Taylor](https://forum.inductiveautomation.com/u/Chris_Taylor)\
**Post date:** [August 29, 2018, 7:14pm UTC](https://forum.inductiveautomation.com/t/writing-in-tables-on-other-windows/19455/2 "2018-08-29T19:14:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 29, 2018, 7:18pm UTC](https://forum.inductiveautomation.com/t/writing-in-tables-on-other-windows/19455/3 "2018-08-29T19:18:22Z")

</div>

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`.

```auto
#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)

```auto
["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`](https://docs.inductiveautomation.com/display/DOC79/system.dataset.deleteRows):

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

```

---

<div class="post-metadata">

**Author:** ![agweb.salinas](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@agweb.salinas](https://forum.inductiveautomation.com/u/agweb.salinas)\
**Post date:** [August 29, 2018, 7:53pm UTC](https://forum.inductiveautomation.com/t/writing-in-tables-on-other-windows/19455/4 "2018-08-29T19:53:37Z")

</div>

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?
