How implement switch in ui_table?

Is it possible to implement a switch in ui_table?

Can you explain your self a bit more? Do you want one of the columns to display a switch's value or something else?

I want to make a table with switches in one row. They should function like a normal switch in Node-Red.

and what would they do? Will the table be a fixed size or variable size? How do you expect the switches to work? Will there be a seperate flow handling each switch?

I would suggest you do a forum search using 'tabulator' and read thru the threads and, more importantly,, read about Tabulator so you will know what it can do and I think that will help you do what you want.

I read it and I'm working on a solution now thx for your help. I will post my solution if I'm finished :slight_smile:

Here is my Flow:

[{"id":"6f27d995.640668","type":"change","z":"f6f2187d.f17ca8","name":"","rules":[{"t":"set","p":"ui_control","pt":"msg","to":"{\"tabulator\":{\"dataTree\":true,\"dataTreeStartExpanded\":true,\"columns\":[{\"title\":\"Woche\",\"field\":\"woche\",\"width\":75,\"responsive\":0},{\"title\":\"Start\",\"field\":\"start\",\"width\":75,\"responsive\":0},{\"title\":\"End\",\"field\":\"end\",\"width\":75,\"editor\":\"input\"},{\"title\":\"Temp\",\"field\":\"temp\",\"width\":75,\"editor\":\"input\"},{\"title\":\"Safe\",\"field\":\"safe\",\"width\":75},{\"title\":\"wie Vortag\",\"field\":\"vortag\",\"formatter\":\"function(cell, formatterParams, onRendered){var html=\\\"<i class=\\\\\\\"\\\";switch(cell.getValue()) {case 0: html+=\\\"fa fa-toggle-off fa-1.5x\\\\\\\" style=\\\\\\\"color:red\\\\\\\"\\\"; break;case 1: html+=\\\"fa fa-toggle-on fa-1.5x\\\\\\\" style=\\\\\\\"color:green\\\\\\\"\\\"; break;}html+='\\\\\\\"></i>';return html; }\",\"width\":75}]}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":780,"wires":[["67b1be0.df80a44"]]},{"id":"67b1be0.df80a44","type":"ui_table","z":"f6f2187d.f17ca8","group":"5757624b.54259c","name":"","order":0,"width":"24","height":"12","columns":[],"outputs":1,"cts":true,"x":570,"y":780,"wires":[["c39762bf.40c33","acf3a34a.846c7"]]},{"id":"9a6e1a06.3e6eb8","type":"inject","z":"f6f2187d.f17ca8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"woche\":\"Montag\",\"start\":\"Bathroom\",\"status\":0,\"safe\":\"Safe\",\"vortag\":1,\"_children\":[{\"woche\":\"\",\"start\":\"00:00\",\"end\":\"16:30\",\"temp\":21},{\"start\":\"16:30\",\"end\":\"23:59\",\"temp\":21}]},{\"woche\":\"Dienstag\",\"status\":0,\"_children\":[{\"woche\":\"tag1\",\"start\":\"heute\"}]}]","payloadType":"json","x":180,"y":780,"wires":[["6f27d995.640668"]]},{"id":"c39762bf.40c33","type":"debug","z":"f6f2187d.f17ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":780,"wires":[]},{"id":"acf3a34a.846c7","type":"function","z":"f6f2187d.f17ca8","name":"","func":"if (msg.topic == \"vortag\"){\n    if (msg.payload.vortag == 0){\n        msg.payload.vortag = 1;\n    } else {\n        msg.payload.vortag = 0;\n    }\n}\n\nvar data = msg.payload;\nmsg.payload = [];\nmsg.payload.push(data);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":840,"wires":[["67b1be0.df80a44"]]},{"id":"5757624b.54259c","type":"ui_group","name":"Group 1","tab":"f5085d6d.61f9a","order":1,"disp":true,"width":"24","collapse":false},{"id":"f5085d6d.61f9a","type":"ui_tab","name":"Wochenplan","icon":"dashboard","order":7,"disabled":false,"hidden":false}]

It isn't finished yet but it works

1 Like

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