Ui-table with handler how to get full table data

Hi there!
I am using ui-table for a while now and just started exploring the ui-table handler.
What I am struggeling with is getting the full table data. The flow variable tableData contains the table data as object with many numbers as keys instead as an array. I am sure there are good reasons to store the data as objects instead of array.

My question is how do I get the table data as array?
OR
How can I make sure that the row indexes cover all numbers continuously? How can I find the highest number or missing number (e.g. 1,2,4,5 => 3) in such kind of object?
How do I find the highest index in order to loop through the rows and perform actions on them?

Maybe I am missing a simple javascript trick here!?

Thanks a lot!
JR

PS: using Version 0.2.1 of the ui-table handler
PPS: winking towards @Christian-Me

Ok, I found the command "getTable". However it keeps giving me the error on the handler node:

TypeError: Cannot set property 'tableArray' of undefined

The flow I use is the example flow of the ui-table handler extended by an inject node that sends:
msg.command = "getTable"
msg.argument = ""

Any hints?

Are you sure that the flow data is not an array already? Please show us an example of the retrieved flow data, if it is an object you can convert it to an array using JSONata($$.payload.*) or Javascript (Object.values(msg.payload))
example

[{"id":"70124611571c8688","type":"inject","z":"366a43adb328cf95","name":"add data","props":[{"p":"payload"},{"p":"tabulatorCommand","v":"addData","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"id\":1,\"one\":1,\"two\":2},{\"id\":2,\"one\":3,\"two\":4}]","payloadType":"json","x":340,"y":1220,"wires":[["e958cb8944b83557"]]},{"id":"e958cb8944b83557","type":"function","z":"366a43adb328cf95","name":"holder for handler","func":"// replace this with handler as forum would not allow upload over limit\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":1260,"wires":[["9a5aa867d645faf3","cda1c69ad8d61397"],["d486767eb2e2ef71"]]},{"id":"98fde25c61e74745","type":"inject","z":"366a43adb328cf95","name":"get data","props":[{"p":"payload.command","v":"getTable","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":340,"y":1360,"wires":[["e958cb8944b83557"]]},{"id":"9a5aa867d645faf3","type":"ui_table","z":"366a43adb328cf95","group":"2d4fe667.28f8ba","name":"","order":16,"width":0,"height":0,"columns":[],"outputs":0,"cts":false,"x":670,"y":1200,"wires":[]},{"id":"cda1c69ad8d61397","type":"debug","z":"366a43adb328cf95","name":"debug 95","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":1260,"wires":[]},{"id":"d486767eb2e2ef71","type":"debug","z":"366a43adb328cf95","name":"debug 96","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":1320,"wires":[]},{"id":"6144472ebcb6bcc8","type":"inject","z":"366a43adb328cf95","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":1440,"wires":[["13d0cd191c15cb59"]]},{"id":"13d0cd191c15cb59","type":"change","z":"366a43adb328cf95","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"tableData","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"$$.payload.*","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1440,"wires":[["6e1e9e7f7b9c25d8"]]},{"id":"6e1e9e7f7b9c25d8","type":"debug","z":"366a43adb328cf95","name":"debug 97","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":1440,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":1,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Below is my flow and output.
So far I never received an output from the ui-table handler when sending the command:"getTable". That means I cannot include an example output array.


image

After sending the command out:
image
image

Thanks for looking into it!

My last flow example shows how to get an array from the context table data.

I skipped using ui-table when I found how difficult it was and went straight to using Tabulator itself in a ui-template node. There's a bit of a learning curve on getting the ui-template node to work and respond, but it's so much cleaner and the documentation is so much better using Tabulator itself (which ui-table is just a wrapper for). As an added plus, it turns a lot of the table processing to the client, which frees up server resources.

Yes, it's a bit of a plug. But I had the most difficult time getting ui-table to do simple stuff like that as well which is why I switched. Haven't looked back since.

OK, I understand now the second flow you made @E1cid.

In the ui-table handler code I saw this section, which seems odd to me as no table data isbeing assigned to either the variable tableArray nor msg.payload. So I guess it is a bug or it is handled at some other point, which I do not understand.

image

and later after pushRowData:

So for now I will try to use your 'external' method.
Thanks!
JR

getTable works for me as shown in the flow and images i showed. I suspect you have a bad setting in your tablehandler config. Would need to see it to confirm though.
[edit] Just noticed getTable should be in msg.payload.command, not msg.command.

The demo does not work at all for me. :frowning:
Which is the latest version of the ui-table handler? I have 0.2.1

For me the table gets no data from the injection node. It shows the error "msg.topic not defined!"
Also the getTable command did not work consequently.

The getTable command seems to be received by the handler, but the code produces an error.
Cheers
JR

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