# Stores data in a table even when it isn’t visible

**URL:** <https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229>\
**Category:** General\
**Tags:** node-red-dashboard, function-node\
**Created:** [7 October 2024 21:36 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229 "2024-10-07T21:36:40Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Desmond-Zeh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/desmond-zeh/32/92216_2.png) [@Desmond-Zeh](https://discourse.nodered.org/u/Desmond-Zeh)\
**Post date:** [7 October 2024 21:36 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/1 "2024-10-07T21:36:40Z")

</div>

Hello!  
I’ve used a ui-table node to display incoming data from my Gensets. Data are only display when the table is active. When I switch to another tab, the data previously filled up in the table will disappeared.  
I will like to store data in the background (when the table is invisible) and then load them to the table when it’s active (visible).  
Please any help on this I’ll gladly appreciate.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 October 2024 22:00 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/2 "2024-10-07T22:00:32Z")

</div>

You could store the data in a context variable then use the UI control node to repopulate the table upon switching pages.

---

<div class="post-metadata">

**Author:** ![Desmond-Zeh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/desmond-zeh/32/92216_2.png) [@Desmond-Zeh](https://discourse.nodered.org/u/Desmond-Zeh)\
**Post date:** [8 October 2024 10:15 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/3 "2024-10-08T10:15:16Z")

</div>

Thank you for your response.  
I've used the context variable as you suggested, but the values keeps on overriding in the context file in my setting.js file. I want new data to be appended to the file and not overrides the existing data.  
Any help....

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [8 October 2024 10:21 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/4 "2024-10-08T10:21:28Z")

</div>

Probably overkill for this, but you can use a database such as SQLite.

The storage of the data is then handled outside of Node-red and the dashboard table populated from an SQL query triggered by an insert/update.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [8 October 2024 11:31 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/5 "2024-10-08T11:31:35Z")

</div>

> [@Desmond-Zeh](#):
>
> I've used the context variable as you suggested, but the values keeps on overriding in the context file in my setting.js file. I want new data to be appended

then update it, dont overwrite it! 🤷

> [@Desmond-Zeh](#):
>
> Any help....

You would have to share a flow or code first. (dont include dashboard nodes, dont include nodes that access things external to node-red since we wont have access to them - basically, use simulation data from injects/functions/templates)

---

<div class="post-metadata">

**Author:** ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)\
**Post date:** [8 October 2024 12:29 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/6 "2024-10-08T12:29:12Z")

</div>

If you are on dashboard 2.0, you can use the `@omrid01/node-red-dashboard-2-table-tabulator` table node, which maintains a live image of the table configuration, data & dynamic styling in the Node-red data store, and populates the table upon opening/refreshing the dashboard clients.

Note, however, that Node-red does not persist this data store, so once you restart the Node-red server process it is lost.

---

<div class="post-metadata">

**Author:** ![Desmond-Zeh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/desmond-zeh/32/92216_2.png) [@Desmond-Zeh](https://discourse.nodered.org/u/Desmond-Zeh)\
**Post date:** [8 October 2024 13:55 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/7 "2024-10-08T13:55:44Z")

</div>

Thank you. I've used the sqlite which is pretty good. I'm able to read data from the sqlite database and display them on the dashboard table upon refresh(ui button).  
The issue is when I refresh my table, new rows and columns will be created in the table with the same data as old ones.  
I will like to add only updated data or new data.  
Any help....

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [8 October 2024 14:00 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/8 "2024-10-08T14:00:14Z")

</div>

Before sending the SQL data to the table send an empty array. This will clear the table.

Instead of keeping the table and appending new rows it will redraw the whole table

---

<div class="post-metadata">

**Author:** ![Desmond-Zeh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/desmond-zeh/32/92216_2.png) [@Desmond-Zeh](https://discourse.nodered.org/u/Desmond-Zeh)\
**Post date:** [8 October 2024 14:19 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/9 "2024-10-08T14:19:42Z")

</div>

I've use a change node to send an empty array into the table.  
When I send the empty array, it creates an empty row below rather than clear the entire table.  
Here below is my code

```auto
{
    "command": "updateOrAddRow",
    "arguments": []
}

```

And here are the corresponding images from my table ui

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/c/5cb7a19b805250bdb3bbbc2cacc78e7b1368ed7b.png)  
After sending the clear command, I got this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/db4e520cc2573b0af13b504d8855b1d084371165.png)  
An additional row is created below...

---

<div class="post-metadata">

**Author:** ![Desmond-Zeh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/desmond-zeh/32/92216_2.png) [@Desmond-Zeh](https://discourse.nodered.org/u/Desmond-Zeh)\
**Post date:** [8 October 2024 14:31 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/10 "2024-10-08T14:31:36Z")

</div>

I just replaced the updateOrAddRow command with replaceData command and it works.  
Thank you once more...

---

<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:** [6 January 2025 14:32 UTC](https://discourse.nodered.org/t/stores-data-in-a-table-even-when-it-isn-t-visible/92229/11 "2025-01-06T14:32:04Z")

</div>

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