# Problem with data displayed in UI-Table when switching Tabs

**URL:** <https://discourse.nodered.org/t/problem-with-data-displayed-in-ui-table-when-switching-tabs/48940>\
**Category:** General\
**Created:** [26 July 2021 21:23 UTC](https://discourse.nodered.org/t/problem-with-data-displayed-in-ui-table-when-switching-tabs/48940 "2021-07-26T21:23:32Z")\
**Posts on this page:** 1\
**Showing post:** 7

<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:** [27 July 2021 16:04 UTC](https://discourse.nodered.org/t/problem-with-data-displayed-in-ui-table-when-switching-tabs/48940/7 "2021-07-27T16:04:33Z")

</div>

So something like a logfile ....

> [@A Syslog Server for the Dashboard](https://discourse.nodered.org/t/a-syslog-server-for-the-dashboard/24337):
>
> Hi perhaps somebody is interested. Just finished a syslog server for the node-red dashboard. It makes use of ui-table. I hope somebody finds it useful. It is build around ui-table and a subflow I use for all kinds of tables in my projects. [https://raw.githubusercontent.com/Christian-Me/node-red-contrib-home/master/Node-RED/syslog/screenshots/demo.gif(image larger than 4096KB)](https://raw.githubusercontent.com/Christian-Me/node-red-contrib-home/master/Node-RED/syslog/screenshots/demo.gif) Features can handle quite huge amounts of data only limited by the clients browser. As every line is sent individual…

This is using a little bit more complex (but universal) subflow I use for all my tables.

But you can do it more simple too:

A) a function node which gets an array (of lines) from the flow context and pushes the new line at the end  
B) a second function node triggered by ui-control gets the same context array and send it to ui-table

I splittend it up to different nodes to make it easier to understand / debug - The tricky part is to scroll the table if you insert your rows at the end of the table.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9c029eb242dd473060544d6532505099dce9164d.png)

```auto
[{"id":"5157b913.480ca8","type":"inject","z":"d1227ddb.952f7","name":"","props":[{"p":"timestamp","v":"","vt":"date"}],"repeat":"10","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":135,"y":578,"wires":[["13f98b83.2e2974"]]},{"id":"13f98b83.2e2974","type":"function","z":"d1227ddb.952f7","name":"demo data","func":"let counter = context.get('counter') || 0;\ncounter++;\ncontext.set('counter',counter);\n\nvar output = {\n payload:{\n id : counter,\n timestamp : msg.timestamp,\n text : `Line #${counter}`,\n value : counter\n }\n}\n\nreturn output;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":308,"y":578,"wires":[["81a5a8e6.5418f8"]]},{"id":"81a5a8e6.5418f8","type":"function","z":"d1227ddb.952f7","name":"store data","func":"let tabledata = flow.get('tabledata') || [];\ntabledata.push(msg.payload);\nflow.set('tabledata',tabledata);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":485,"y":578,"wires":[["d6ec8129.da035"]],"icon":"node-red/db.svg"},{"id":"d6ec8129.da035","type":"function","z":"d1227ddb.952f7","name":"addData","func":"// http://tabulator.info/docs/4.9/update#alter-add\nvar output={\n payload:{\n command: \"addData\",\n arguments: [\n [msg.payload],\n false\n ]\n }\n }\n\n// http://tabulator.info/docs/4.9/navigation#scroll-row\nvar scroll={\n payload:{\n command: \"scrollToRow\",\n arguments: [\n msg.payload.id,\n \"top\",\n true\n]\n } \n}\nreturn [[output,scroll]];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":655,"y":578,"wires":[["82bc171.d9d5de8","1c88a7d4.6e7b88"]],"icon":"font-awesome/fa-table"},{"id":"f9eb75ea.c53888","type":"ui_ui_control","z":"d1227ddb.952f7","name":"","events":"all","x":315,"y":646,"wires":[["75d7057b.e0eeec"]]},{"id":"75d7057b.e0eeec","type":"function","z":"d1227ddb.952f7","name":"get data","func":"msg.payload = flow.get('tabledata') || [];\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":485,"y":646,"wires":[["82bc171.d9d5de8"]],"icon":"node-red/db.svg"},{"id":"82bc171.d9d5de8","type":"ui_table","z":"d1227ddb.952f7","group":"5bf56b63.75b254","name":"","order":0,"width":"6","height":"7","columns":[],"outputs":0,"cts":false,"x":833,"y":612,"wires":[]},{"id":"1c88a7d4.6e7b88","type":"debug","z":"d1227ddb.952f7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":832,"y":578,"wires":[]},{"id":"5bf56b63.75b254","type":"ui_group","name":"Logfile","tab":"bae8e16f.a9faa","order":2,"disp":true,"width":"6","collapse":true},{"id":"bae8e16f.a9faa","type":"ui_tab","name":"ui-table","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

_[View the full topic](https://discourse.nodered.org/t/problem-with-data-displayed-in-ui-table-when-switching-tabs/48940)._
