# UI-Table download/export filtered data on columns

**URL:** https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252
**Category:** Dashboard
**Created:** [31 August 2020 12:44 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252 "2020-08-31T12:44:45Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![dptek](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@dptek](https://discourse.nodered.org/u/dptek)
#### Post date: [31 August 2020 12:44 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/1 "2020-08-31T12:44:45Z")

</div>

Hi,

I successfully added [filters](http://tabulator.info/examples/4.7?#filter-header) to the columns of my table, but now I want to be able to download the filtered data as CSV or just get the filtered data and create myself the CSV file.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57877a0f70b3db27edcf23f20da4a38e2f00413d.png)

I think one of these 3 options suits me (in order of preference):

1. Call the built-in [download/export](http://tabulator.info/examples/4.7?#download) function using the template node. But I have no idea how to call functions of the ui table.
2. Send a command to request all visible data, if even exists. The quick info documentation only shows 3 commands. Where can I find the list of commands?
3. Have a callback function when the filters are applied. If someone has an example it would be great.

Any help?  
Thanks in advance.

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [31 August 2020 15:34 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/2 "2020-08-31T15:34:33Z")

</div>

Only a quick answer to your point 2.  
All you can do (commands, callbacks, parameters ...) are well documented @ tabulator website.  
ui-table only acts as an interface.  
I think everything you can do with tabulator should be doable through ui-table

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [31 August 2020 15:39 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/3 "2020-08-31T15:39:00Z")

</div>

> Tabulator allows you to download/export the table data as a file directly from your browser, no server needed.

> The download will contain the text values of all data currently visible in the table, matching the current column layout, column titles, sorting and filtering.

> **[Tabulator - Download Data](https://tabulator.info/docs/4.0/download)**
>
> Download data from your table in a range of popular file formats

Hope this functionality already exists in 3.7 which is the version ui-table currently use.

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [31 August 2020 15:46 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/4 "2020-08-31T15:46:18Z")

</div>

To 1.  
I would use a normal dashboard button and send a command to ui-table to trigger the export function.

See the commands part in the ui-table readme to know more about formatting the message to ui-table

And finally to 3.

> **[Tabulator - Interactive JavaScript Tables](http://tabulator.info/docs/4.0/callbacks#filter)**
>
> Create interactive data tables in seconds with Tabulator. A lightweight, fully featured JavaScript table generation library.

---

<div class="post-metadata">

### Author: ![dptek](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@dptek](https://discourse.nodered.org/u/dptek)
#### Post date: [31 August 2020 18:57 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/5 "2020-08-31T18:57:03Z")

</div>

> [@Christian-Me](#):
>
> export function

Where can I find the export function command? The [readme](https://github.com/node-red/node-red-ui-nodes/blob/master/node-red-node-ui-table/README.md) file only mentions _addRow_, _replaceData_ or _addFilter_ and says:

> Beside data manipulation you can [set filters](http://tabulator.info/docs/4.5/filter#func) and do many other things with commands.

I have tried sending commands _getData_, _getFilters_, _getHeaderFilters_ and none of them works. I still don't know where to find the list if the supported commands, I am just assuming they are the names of the available functions.

---

<div class="post-metadata">

### Author: ![dptek](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@dptek](https://discourse.nodered.org/u/dptek)
#### Post date: [31 August 2020 19:03 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/6 "2020-08-31T19:03:01Z")

</div>

> [@Christian-Me](#):
>
> part

Adding the callback function gives the error _InternalError: too much recursion_ on the browser console and my data is fails to load. This is the callback definition I added to msg.ui\_control.tabulator:

`dataFiltered: "function(filters, rows){this.send({ui_control:{callback:'dataFiltered'}, filters: filters, rows: rows}); }",`

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [31 August 2020 20:23 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/7 "2020-08-31T20:23:54Z")

</div>

As mentioned here

> [@Ui-table supports ui\_control](https://discourse.nodered.org/t/ui-table-supports-ui-control/18870/14):
>
> Hi Andy, Rows is not a JavaScript object per se it is a component which can not be transferred to a JSON formatted sting. You can/should access the data by the included methods. This is why the send method fails. You can pick the relevant data by using the methods in a new object and send this back to the runtime. Here is an example for the cell component So your error is not directly related to the loopback issue - your error is caused by trying to convert a component to a json string. …

Rows is a component and can‘t be converted into a JSON string to be sent from the frontend to the backend (node-red)

You have to use the methods to pic the data items.

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [31 August 2020 20:30 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/8 "2020-08-31T20:30:37Z")

</div>

```auto
table.download("csv", "data.csv"); //download table data as a CSV formatted file with a file name of data.csv

```

As described in the tabulator doc I linked before:

> **[Tabulator - Interactive JavaScript Tables](http://tabulator.info/docs/4.0/download)**
>
> Create interactive data tables in seconds with Tabulator. A lightweight, fully featured JavaScript table generation library.

And the ui-table readme and the examples how to build the message to be sent to ui-table

---

<div class="post-metadata">

### Author: ![dptek](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@dptek](https://discourse.nodered.org/u/dptek)
#### Post date: [1 September 2020 07:24 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/9 "2020-09-01T07:24:08Z")

</div>

> [@Christian-Me](#):
>
> Rows is a component and can‘t be converted into a JSON string to be sent from the frontend to the backend (node-red)
> 
> You have to use the methods to pic the data items.

Thanks for the hints. Sorry for my lack of knowledge in JavaScript/NodeJS stuff.

I now have access to the data, but my requirements changed a little and now I need the applied filters. The problem is that the _'filters'_ parameter on the _'dataFiltered'_ and _'dataFiltering'_ callbacks are always zero length arrays. I inspected the _'rows'_ parameter but couldn't find the applied filters either. Am I doing something wrong?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/faeb7f9e11ea47a1599dde0192e4497cec7002b2.png)

---

<div class="post-metadata">

### Author: ![dptek](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@dptek](https://discourse.nodered.org/u/dptek)
#### Post date: [1 September 2020 08:58 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/10 "2020-09-01T08:58:02Z")

</div>

Just found the get filters method from the rows elements.  
`rows[0]._row.table.getHeaderFilters()`  
My programming experience tells me this is not a good practice, but my ignorance in JS makes me doubt about my first assumption.

---

<div class="post-metadata">

### Author: ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)
#### Post date: [7 September 2020 21:10 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/11 "2020-09-07T21:10:38Z")

</div>

Hi,

sorry I do not have time to dig in deeper. Accessing prototype properties (\_) directly is not "best practice", because if the implementations changes in the future you have the risk that your code could be broken. Best is to find a get method to access the properties you need.

Chris

---

<div class="post-metadata">

### Author: ![betternoel](https://avatars.discourse-cdn.com/v4/letter/b/90db22/32.png) [@betternoel](https://discourse.nodered.org/u/betternoel)
#### Post date: [17 September 2020 03:50 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/12 "2020-09-17T03:50:35Z")

</div>

this is the far i could understand on how to build the message to be sent to ui-table  
msg.ui\_control = {  
"tabulator":{  
"command":"download",  
"arguments":[  
{  
"type": "csv",  
"name": "feeder41.csv"  
}  
]  
}  
}

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [17 October 2020 03:50 UTC](https://discourse.nodered.org/t/ui-table-download-export-filtered-data-on-columns/32252/13 "2020-10-17T03:50:43Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
