node-red-ui-nodes icon indicating copy to clipboard operation
node-red-ui-nodes copied to clipboard

updateOrAddData in Table not working

Open derFrickler opened this issue 5 years ago • 2 comments

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 http://homeserver:1880/ui/js/app.min.js line 571 > eval:145 $digest http://homeserver:1880/ui/js/app.min.js:172 $apply http://homeserver:1880/ui/js/app.min.js:176 r http://homeserver:1880/ui/js/app.min.js:190 completeTask http://homeserver:1880/ui/js/app.min.js:187 d http://homeserver:1880/ui/js/app.min.js:73 setTimeout handler*Ag/h.defer http://homeserver:1880/ui/js/app.min.js:72 f http://homeserver:1880/ui/js/app.min.js:190 t http://homeserver:1880/ui/js/app.min.js:569 emit http://homeserver:1880/ui/socket.io/socket.io.js:6 onevent http://homeserver:1880/ui/socket.io/socket.io.js:8 onpacket http://homeserver:1880/ui/socket.io/socket.io.js:8 exports http://homeserver:1880/ui/socket.io/socket.io.js:8 emit http://homeserver:1880/ui/socket.io/socket.io.js:6 ondecoded http://homeserver:1880/ui/socket.io/socket.io.js:6 exports http://homeserver:1880/ui/socket.io/socket.io.js:8 emit http://homeserver:1880/ui/socket.io/socket.io.js:6 add http://homeserver:1880/ui/socket.io/socket.io.js:6 ondata http://homeserver:1880/ui/socket.io/socket.io.js:6 exports http://homeserver:1880/ui/socket.io/socket.io.js:8 emit http://homeserver:1880/ui/socket.io/socket.io.js:6 onPacket http://homeserver:1880/ui/socket.io/socket.io.js:6 setTransport http://homeserver:1880/ui/socket.io/socket.io.js:6 emit http://homeserver:1880/ui/socket.io/socket.io.js:6 onPacket http://homeserver:1880/ui/socket.io/socket.io.js:7 onData http://homeserver:1880/ui/socket.io/socket.io.js:7 onmessage http://homeserver:1880/ui/socket.io/socket.io.js:8

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.

derFrickler avatar Sep 08 '20 10:09 derFrickler

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"

image

Christian-Me avatar Nov 17 '20 23:11 Christian-Me

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.

andersea avatar Jan 08 '21 18:01 andersea