node-red-ui-nodes
node-red-ui-nodes copied to clipboard
updateOrAddData in Table not working
Which node are you reporting an issue on?
ui-table
What are the steps to reproduce?
send this message to table:
{"command":"updateOrAddData","arguments":[{"linkquality":2,"name":"Router_KG","id":1}]}
What happens?
No Row is added to the table, the Browser shows the following error:
Uncaught (in promise) TypeError: data.forEach is not a function
updateOrAddData http://homeserver:1880/ui/#!/0#/0 line 20 > injectedScript:8221
updateOrAddData http://homeserver:1880/ui/#!/0#/0 line 20 > injectedScript:8207
What do you expect to happen?
Row should be added or replaced in the table.
Please tell us about your environment:
- [ 1.1.03] Node-RED version:
- [v10.22.0 ] node.js version:
- [ ] npm version:
- [Ubuntu Linux] Platform/OS:
- [ Firefox] Browser:
Might be the same as there: https://stackoverflow.com/questions/53275405/typeerror-data-foreach-is-not-a-function/53275463 Meaning the data object needs to be parsed on arrival, but no Idea on where to add this.
Hi @derFrickler
sorry I haven't spotted your issue.
Think I spotted your problem.
UpdateOrAddData expects an array as you can add multiple clees / lines in one command. Arguments is an array of arguments itself. So:
{"command":"updateOrAddData",
"arguments":[
[
{"linkquality":2,"name":"Router_KG","id":1}
]
]
}
should work. ui-table does not perform a validation of commands and parameters.
As a "testbench" you can use the Example "4 Sending Commands"

I had a similar issue with the replaceData function. It wasn't obvious to me that I needed to encapsulate the data in another array.