Push data from inject node to ui table

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

Please help me!

Best to always search forum first.
Which would of provided this example
Which may be of help to you.

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

But don't find any suitable solution


I doing like this

What about the example provided by @E1cid

Have you tried it?

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?

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

[{"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}]

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 ```)

``` 
   code goes here 
```

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

See this post for more details - How to share code or flow json

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

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