# Push data from inject node to ui table

**URL:** <https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426>\
**Category:** Dashboard\
**Created:** [9 August 2023 07:07 UTC](https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426 "2023-08-09T07:07:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![taneshgyr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/taneshgyr/32/81890_2.png) [@taneshgyr](https://discourse.nodered.org/u/taneshgyr)\
**Post date:** [9 August 2023 07:07 UTC](https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426/1 "2023-08-09T07:07:03Z")

</div>

const MAX\_ROWS = 4;

// Initialize an array to store the injected values  
let tableData = flow.get('tableData') || ;

// Injected data from the payload  
let injectedValue = msg.payload;

// Add the new value to the tableData array  
tableData.push(injectedValue);

// Limit the table data to a maximum of MAX\_ROWS items  
if (tableData.length \> MAX\_ROWS) {  
tableData.shift(); // Remove the first (oldest) row  
}

// Update the context with the modified tableData array  
flow.set('tableData', tableData);

// Prepare data for display in the ui\_table  
msg.payload = tableData.map(item =\> [  
item.type,  
item.waht,  
item.volt  
]);

return msg;

This is the code in the function node, still data is not displaying in the table

 ![image_2023-08-09_150441481](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd61c487e4ce091d9dfdb401c8a4c6b64870df54.png)

Please help me!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [9 August 2023 07:16 UTC](https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426/2 "2023-08-09T07:16:51Z")

</div>

Best to always [search forum](https://discourse.nodered.org/search?expanded=true&q=updating%20ui-table) first.  
Which would of provided this [example](https://discourse.nodered.org/t/problem-updating-ui-table/78565/2)  
Which may be of help to you.

There are also extensive example in the import flow \> examples, for the ui-table.

---

<div class="post-metadata">

**Author:** ![taneshgyr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/taneshgyr/32/81890_2.png) [@taneshgyr](https://discourse.nodered.org/u/taneshgyr)\
**Post date:** [9 August 2023 07:22 UTC](https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426/3 "2023-08-09T07:22:57Z")

</div>

But don't find any suitable solution

---

<div class="post-metadata">

**Author:** ![taneshgyr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/taneshgyr/32/81890_2.png) [@taneshgyr](https://discourse.nodered.org/u/taneshgyr)\
**Post date:** [9 August 2023 07:23 UTC](https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426/4 "2023-08-09T07:23:53Z")

</div>

![image_2023-08-09_152327616](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d7864dd9b4422004a0e8129d65d96eed31389ac.png)  
I doing like this

---

<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:** [9 August 2023 10:04 UTC](https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426/5 "2023-08-09T10:04:44Z")

</div>

> [@taneshgyr](#):
>
> don't find any suitable solution

What about the example provided by @E1cid

> [@E1cid](#):
>
> Which would of provided this [example](https://discourse.nodered.org/t/problem-updating-ui-table/78565/2)

Have you tried it?

> [@taneshgyr](#):
>
> ![image_2023-08-09_152327616](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d7864dd9b4422004a0e8129d65d96eed31389ac.png)
> 
> I doing like

We can't read what is inside of a screenshot so that doesn't really help us to help you. Perhaps you could share that as a flow?

---

<div class="post-metadata">

**Author:** ![taneshgyr](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/taneshgyr/32/81890_2.png) [@taneshgyr](https://discourse.nodered.org/u/taneshgyr)\
**Post date:** [10 August 2023 04:02 UTC](https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426/6 "2023-08-10T04:02:48Z")

</div>

[moderator note: fixed flow so it could be copied]

```auto
[{"id":"5ce253b4.6b9864","type":"ui_ui_control","z":"74993f0abb9af782","name":"","events":"all","x":220,"y":200,"wires":[["b6b6f332.9b9b5"]]},{"id":"b6b6f332.9b9b5","type":"change","z":"74993f0abb9af782","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":200,"wires":[["c4004ac2.a0e16","6178007a.9be93c"]]},{"id":"c4004ac2.a0e16","type":"function","z":"74993f0abb9af782","name":"Process Data","func":"const MAX_ROWS = 5; // Maximum number of rows in the table\n\n// Initialize an array to store the table data\nlet tableData = flow.get('tableData') || [];\n\n// Injected data from the payload\nlet injectedValue = msg.payload;\n\n// Add the new value to the beginning of the tableData array\ntableData.unshift(injectedValue);\n\n// Limit the table data to a maximum of MAX_ROWS items\nif (tableData.length > MAX_ROWS) {\n tableData.pop(); // Remove the last (oldest) row\n}\n\n// Update the context with the modified tableData array\nflow.set('tableData', tableData);\n\n// Prepare data for display in the ui_table\nmsg.payload = tableData.map(item => [\n item.type,\n item.waht,\n item.volt\n]);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":200,"wires":[["a14e9f16.b4c43"]]},{"id":"a14e9f16.b4c43","type":"ui_table","z":"74993f0abb9af782","group":"dbb04962.5721c8","name":"","order":0,"width":"8","height":"6","columns":[{"field":"type","title":"Type"},{"field":"waht","title":"WAHT"},{"field":"volt","title":"Volt"}],"outputs":0,"cts":false,"x":780,"y":200,"wires":[]},{"id":"6178007a.9be93c","type":"debug","z":"74993f0abb9af782","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":260,"wires":[]},{"id":"dbb04962.5721c8","type":"ui_group","name":"Table Group","tab":"b76d228f.48ea2","order":1,"disp":true,"width":"8","collapse":false},{"id":"b76d228f.48ea2","type":"ui_tab","name":"Table Tab","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [10 August 2023 11:09 UTC](https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426/7 "2023-08-10T11:09:42Z")

</div>

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<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:** [10 August 2023 11:29 UTC](https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426/8 "2023-08-10T11:29:10Z")

</div>

The last flow you posted has no input data going into it.

---

<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 September 2023 11:29 UTC](https://discourse.nodered.org/t/push-data-from-inject-node-to-ui-table/80426/9 "2023-09-09T11:29:54Z")

</div>

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