# How implement switch in ui\_table?

**URL:** <https://discourse.nodered.org/t/how-implement-switch-in-ui-table/42467>\
**Category:** General\
**Created:** [11 March 2021 10:22 UTC](https://discourse.nodered.org/t/how-implement-switch-in-ui-table/42467 "2021-03-11T10:22:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![multixz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/multixz/32/39420_2.png) [@multixz](https://discourse.nodered.org/u/multixz)\
**Post date:** [11 March 2021 10:22 UTC](https://discourse.nodered.org/t/how-implement-switch-in-ui-table/42467/1 "2021-03-11T10:22:11Z")

</div>

Is it possible to implement a switch in ui\_table?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 March 2021 10:58 UTC](https://discourse.nodered.org/t/how-implement-switch-in-ui-table/42467/2 "2021-03-11T10:58:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![multixz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/multixz/32/39420_2.png) [@multixz](https://discourse.nodered.org/u/multixz)\
**Post date:** [11 March 2021 12:01 UTC](https://discourse.nodered.org/t/how-implement-switch-in-ui-table/42467/3 "2021-03-11T12:01:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 March 2021 12:09 UTC](https://discourse.nodered.org/t/how-implement-switch-in-ui-table/42467/4 "2021-03-11T12:09:53Z")

</div>

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](http://tabulator.info) so you will know what it can do and I think that will help you do what you want.

---

<div class="post-metadata">

**Author:** ![multixz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/multixz/32/39420_2.png) [@multixz](https://discourse.nodered.org/u/multixz)\
**Post date:** [11 March 2021 12:18 UTC](https://discourse.nodered.org/t/how-implement-switch-in-ui-table/42467/5 "2021-03-11T12:18:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![multixz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/multixz/32/39420_2.png) [@multixz](https://discourse.nodered.org/u/multixz)\
**Post date:** [11 March 2021 12:21 UTC](https://discourse.nodered.org/t/how-implement-switch-in-ui-table/42467/6 "2021-03-11T12:21:44Z")

</div>

Here is my Flow:

```auto
[{"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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 May 2021 12:22 UTC](https://discourse.nodered.org/t/how-implement-switch-in-ui-table/42467/7 "2021-05-10T12:22:33Z")

</div>

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