# Passing Dataset to Component

**URL:** <https://forum.inductiveautomation.com/t/passing-dataset-to-component/78177>\
**Category:** General Discussion\
**Tags:** perspective, ignition81, scripting\
**Created:** [August 21, 2023, 7:03pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-to-component/78177 "2023-08-21T19:03:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Subin\_Adhikari](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@Subin\_Adhikari](https://forum.inductiveautomation.com/u/Subin_Adhikari)\
**Post date:** [August 21, 2023, 7:03pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-to-component/78177/1 "2023-08-21T19:03:31Z")

</div>

Dear Gurus,  
Need help here ( I am a total Newbie here exploring ignition and just completed IU Lessons )

1. I Have a page intended to be used as Component , in Page Props I here have Prop named "Table" , this page just have one Table Component whose data databinding is set the the abovementioned Prop
2. I have a second page where I have a simple table and want to pass the Page Table data to the step 1 Component Table.

I have passed the data as toDataSet({../Table.props.data}) as well as {../Table.props.data} in second attempt.

how do I achieve this, my current flow passes extra not needed data to the component table as shown in the picture. please help. ( the top table is the table on component page and I am trying to pass data from the bottom table to the component page )

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/f/5febee46bc7d64b97d257f69ffa6b22c19173e5b.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 21, 2023, 8:57pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-to-component/78177/2 "2023-08-21T20:57:21Z")

</div>

We need to fix some terminology here. I think this is what you mean:

> 1. I Have a ~~page~~ **view** intended to be used ~~as Component~~ **in an embedded view**. ~~, in Page Props I here have Prop named "Table" ,~~ **In this view I have a view parameter named "Table".** This ~~page~~ **view** just has one table component whose data binding is set the the above-mentioned ~~Prop~~ **parameter**.
> 2. I have a second ~~page~~ **view** where I have a simple table and want to pass the ~~Page table data to the step 1 table component.~~

A **page** is a collection of one or more views and is created in the **Page Configuration** section of Designer.

I'm not quite sure what you are trying to do but I think you can do what you want if you create a custom property on the main view. Bind both tables to that custom property. The one that needs to _write_ to that custom property needs to have **bidirectional** enabled.

This method creates a kind of global variable that is available to all components (including embedded views) inside the main view.

---

<div class="post-metadata">

**Author:** ![Subin\_Adhikari](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@Subin\_Adhikari](https://forum.inductiveautomation.com/u/Subin_Adhikari)\
**Post date:** [August 21, 2023, 9:40pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-to-component/78177/3 "2023-08-21T21:40:36Z")

</div>

yes pardon for my terminology but you have put it exact what I mean to convey.  
This is my current setup  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/8/78bd3074a70f9218aa0a07907f0500544f291f57.png)

I want to pass the data of TestPage "Table" to SaveToExcel view "Table" ( which finally will be removed and only "Save\_Excel" will be there)

On SaveToExcel view I have PARAMS as  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/4/a49b7ea1eac7f1f28a81db38d75732a2ac957bc2.png)

and on Table at "SaveToExcel" View I have set binding as  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/1/716bce1cfd9e7732d7d9496f807897d8785b9e44.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/b/2bbe9c985379c0ff0d77612acd7929c3f265c62a.png)

the Table at "TestPage" View don't have any bindings and just a plain table dragged from Components.  
the embeddedview in "TestPage" has following props setup  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/0/f0fcc0b89b64484fc58db0add3f7444483e29d0a.png)  
the 'Table' in that prop has binding as  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/0/30b99f2532e38f069789abee5870fb250a982a41.png)

Hope this clarify my question.

---

<div class="post-metadata">

**Author:** ![Subin\_Adhikari](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@Subin\_Adhikari](https://forum.inductiveautomation.com/u/Subin_Adhikari)\
**Post date:** [August 21, 2023, 10:01pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-to-component/78177/4 "2023-08-21T22:01:42Z")

</div>

changing binding to {../Table.props.data} from toDataSet({../Table.props.data}) solved my issue.  
thank you for letting me know the right terminology though @Transistor , appreciated.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 21, 2023, 10:09pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-to-component/78177/5 "2023-08-21T22:09:03Z")

</div>

I don't see the need for `toDataSet` as the data required by SaveToExcel.Table.data will be exactly the same as TestPage.Table.data. (I see you realised this as I was typing this post.)

In any case, a better solution is to use message handlers. When `Save_Excel` button is pressed it should send a message to TestPage.Table and get _it_ to save the data (since it already has it).

- Right click on the button.
- Configure Events, onActionPerformed, +, Script and add the following code:  
`system.perspective.sendMessage("SaveExcel", {}, "page")`

[https://docs.inductiveautomation.com/display/DOC81/system.perspective.sendMessage](https://docs.inductiveautomation.com/display/DOC81/system.perspective.sendMessage)

Now you need to create a message handler on `TestPage.Table`.

- Right click on the table.
- Configure Scripts, Message Handler, + Add Handler, Message Type = _SaveExcel_, Listen Scope = _Page_.
- In the Script section add in the code to save the data.

The big advantage with this is that it will still work if you move stuff around or wrap the table in a container, etc., - all things which can break your application otherwise as the relative paths don't update automatically.

[https://docs.inductiveautomation.com/display/DOC81/Component+Message+Handlers](https://docs.inductiveautomation.com/display/DOC81/Component+Message+Handlers)

---

<div class="post-metadata">

**Author:** ![Subin\_Adhikari](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@Subin\_Adhikari](https://forum.inductiveautomation.com/u/Subin_Adhikari)\
**Post date:** [August 21, 2023, 10:46pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-to-component/78177/6 "2023-08-21T22:46:40Z")

</div>

Hello @Transistor ,  
Thank you so much for your suggestion. I might sound silly but please forgive as I am a newbie in Ignition.

I might have more than 10-15 Tables(in multiple views) which needs to have "Save to Excel" button Functionality so was trying to make it a dynamic button so just Drag and drop the "Save To Excel" View and configure two paramaters ( TableData and SheetName )

According to your suggestion I have to go-to every table and configure a Message Handler in all the tables, for my scenario instead of having a button on Every Table with the code to save to excel I was trying to achieve it dynamically. any other suggestion you might have in my case ? May be passing the table name instead of table data sounds good ?

Thank you and Regards.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 22, 2023, 9:29pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-to-component/78177/7 "2023-08-22T21:29:20Z")

</div>

> [@Subin\_Adhikari](#):
>
> I might have more than 10-15 Tables(in multiple views) which needs to have "Save to Excel" button Functionality

Well then put a button on each view, have the button call a gateway script and pass `Table.data` into the gateway script.

But why not have just one view with a table and button and switch the table contents as required?

---

<div class="post-metadata">

**Author:** ![Subin\_Adhikari](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@Subin\_Adhikari](https://forum.inductiveautomation.com/u/Subin_Adhikari)\
**Post date:** [August 22, 2023, 9:56pm UTC](https://forum.inductiveautomation.com/t/passing-dataset-to-component/78177/8 "2023-08-22T21:56:01Z")

</div>

> [@Transistor](#):
>
> Well then put a button on each view, have the button call a gateway script and pass `Table.data` into the gateway script.

The best way to solve my problem is this way, and I will learn how to achieve this Thanks

> [@Transistor](#):
>
> But why not have just one view with a table and button and switch the table contents as required?

This don't work for me as multiple tables have multiple view with their own filters and other buttons.

Thank you for your support @Transistor , Appreciated.
