# Can't update table cell data dynamically

**URL:** <https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133>\
**Category:** Dashboard\
**Created:** [23 May 2020 12:27 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133 "2020-05-23T12:27:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)\
**Post date:** [23 May 2020 12:27 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/1 "2020-05-23T12:27:21Z")

</div>

I'm trying to dynamically update a cells data in a table as below i.e. change the displayed SSID in the table when it is updated.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/3/f3f320c89ffc7d67dd12752c52064d91b94fe74c.png)

My function is as below (currently testing with static table index ID):  
msg.payload = {  
"command":"updateData",  
"arguments":[  
{  
"id":3,  
"name":flow.get("wlanName"),  
"ssid":newSSIDname  
},  
//true  
],  
}  
return msg;

This output from function node into the table looks correct, but the table contents don't get dynamically refreshed as I expected, I have to manually refresh to see the updated data.

If i use replaceData instead of updateData the table get cleared and shows nothing until I reselect its parent entity.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/22264b7590d31123c28def9cbca3f4c7ed9f2bba.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 May 2020 12:55 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/2 "2020-05-23T12:55:24Z")

</div>

do a forum search using 'crud table' and you should find some ideas

---

<div class="post-metadata">

**Author:** ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)\
**Post date:** [23 May 2020 13:14 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/3 "2020-05-23T13:14:50Z")

</div>

Thx for responding. Tried that, but can't say either of the 2 hits I found enlightened me ☹  
I'm using the Tabulator for my 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:** [23 May 2020 13:33 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/4 "2020-05-23T13:33:00Z")

</div>

Hi, The problem lies in your `msg.payload.arguments` object. Arguments is an array of arguments (some commands have more than one). I would use "updateOrAddData" in your case. It expect as the first argument an array of rows (same as "updateData")! "updateData" only updates existing rows as updateOrAddData will add a new row if the line not exist.

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

---

<div class="post-metadata">

**Author:** ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)\
**Post date:** [23 May 2020 16:08 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/5 "2020-05-23T16:08:20Z")

</div>

Hi Chris - thx for the suggestion, unfortunately its not moved me on. The table cell content doesn't dynamically update in the Dashboard view when I inject the new cell data.  
Maybe my expectation is wrong - if the table is in view and I update contents maybe the view isn't updated until I refresh the table view i.e. the command only updates the table data in memory (that would seem bonkers to me, but hey)?

---

<div class="post-metadata">

**Author:** ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)\
**Post date:** [23 May 2020 19:24 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/6 "2020-05-23T19:24:08Z")

</div>

Driving drive me nuts so taken it back to most basic:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fb3a35c2ef31c435d99822bc96a551b722f60fea.png)  
Top function adds 2 rows into the table - this works fine:  
msg.payload =  
[{  
"name":"SSID-1",  
"ssid":"SSID-1"  
},  
{  
"name":"SSID-2",  
"ssid":"SSID-2"  
}]  
return msg;

Bottom function should change the 2nd row – nothing happens, no errors in console. Its not just a display issue - I enabled click on table row to send output and debug connected to that still shows the original table data.  
msg.payload = {  
"command":"updateOrAddData",  
"arguments":[{  
"id":1,  
"name":"WLAN3",  
"ssid":"SSID-3"  
}, ],  
}  
return msg;

---

<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:** [23 May 2020 20:29 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/7 "2020-05-23T20:29:18Z")

</div>

Precisely - if the tab where the table sits is Not the active one than there is no tabulator table existing to be updated. But it is not impossible to do what you plan to do.

> [@UI-Table: how to use commands to add / update table content dynamically](https://discourse.nodered.org/t/ui-table-how-to-use-commands-to-add-update-table-content-dynamically/23240/13):
>
> OK I looked into it. This problem is more general for more complex widgets (witches which not only display a single value as text or gauge) If a widget is not on the actual tab the dashboard stores the last message to replay it as soon the widget gets visible again. because the widget does not exists on the client side when you are on a different tab and click on the button this fails. But this "simple" general purpose approach is not working for more complex widgets like ui-table with command…

So you need something infront of ui-table to take care of holding the data and replays it if the tab gets visible.

Or here: [[Announce] remote device table (and collaboration wanted)](https://discourse.nodered.org/t/announce-remote-device-table-and-collaboration-wanted/22505)

Or here:

> [@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…

They all use a subflow taking care of handling the table data and layout.

The dashboard replay the last message to a widget when a client connects. This is why your first example work the hole table in one array. The idea using commands is to be able to update any part of the table down to cell level without sending the hole table every time. This is why the syslog table can hold thousands of lines easily and updates as quick as when there are only 10 lines.  
Hope the UI-table handler will help you. It takes a little bit of reading but i use ot in many flows with ui table. You can even configure it that the tabe data survives a Node-RED restart

---

<div class="post-metadata">

**Author:** ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)\
**Post date:** [24 May 2020 08:50 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/8 "2020-05-24T08:50:00Z")

</div>

A colleague noticed I was missing an extra pair of brackets around the update argument. When I added these it started to dynamically add the row into the table, but not change existing cell data based on the index # I specified.

I assumed that the row number in the table automatically = the index ID - wrong! Found this in the Tabulator docs:  
"A unique index value should be present for each row of data if you want to be able to programmatically alter that data at a later point, this should be either numeric or a string. By default Tabulator will look for this value in the id field for the data. If you wish to use a different field as the index, set this using the index option parameter."

So once I also added index ID's to my input array data then I could dynamically change the displayed table contents. Simple when you know how!

This is after injecting initial array data (top function node in my attached flow):  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/adc84f907d48911e4b54e8d44c59f5736556b192.png)  
This is after injecting the updated data (bottom node in my attached flow) - the table data in the Dashboard is updated dynamically:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/4/f4a98bc1f14de44268180ccd1bbeee36a2b7833f.png)  
[Update Table Cell Data.json](https://discourse.nodered.org/uploads/short-url/j1PGnfiVRHVVNESxwfEddbglwK3.json) (2.0 KB)

---

<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:** [24 May 2020 12:31 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/9 "2020-05-24T12:31:13Z")

</div>

Nice you found a solution. The brackets [] are defining the „extra“ Array I mentioned in my first post.  
You can define your index column as you like via `msg.ui_control.tabulator={‚index‘:‘myIndex‘}` So in your case the wifi STA MAC could be a good index.

You still have to deal with the fact that the table only updates when visible and do not store the data by itself. See my post above. I highly recommend the ui-table handler when you use ui-table with dynamic updates.

---

<div class="post-metadata">

**Author:** ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)\
**Post date:** [26 May 2020 08:41 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/10 "2020-05-26T08:41:41Z")

</div>

Thx very much for the additional notes. I'm just learning node-red and JS so a lot swimming around my head - sometimes how "a" relates to "z" is not obvious 😉 Tips on how to improve things welcome. 👍

---

<div class="post-metadata">

**Author:** ![notnice](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@notnice](https://discourse.nodered.org/u/notnice)\
**Post date:** [26 May 2020 08:52 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/11 "2020-05-26T08:52:54Z")

</div>

BTW: each WLAN has a unique index # which I was already setting as a flow variable, so I just use that as the row index in the table:

msg.payload = {  
"command":"updateData",  
"arguments":[  
[{  
**"id":flow.get("wlanID")**, //WLAN ID from original WLAN request and required to update correct row  
"ssid":newSSIDname //Set the new SSID name  
},]  
],  
}

---

<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:** [9 June 2020 08:52 UTC](https://discourse.nodered.org/t/cant-update-table-cell-data-dynamically/27133/12 "2020-06-09T08:52:58Z")

</div>

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