# Node-RED: Tabulator Column Not Hiding

**URL:** <https://discourse.nodered.org/t/node-red-tabulator-column-not-hiding/92759>\
**Category:** General\
**Tags:** node-red-dashboard, dashboard-2\
**Created:** [29 October 2024 06:35 UTC](https://discourse.nodered.org/t/node-red-tabulator-column-not-hiding/92759 "2024-10-29T06:35:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nandhini-Subramaniya](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nandhini-subramaniya/32/92882_2.png) [@Nandhini-Subramaniya](https://discourse.nodered.org/u/Nandhini-Subramaniya)\
**Post date:** [29 October 2024 06:35 UTC](https://discourse.nodered.org/t/node-red-tabulator-column-not-hiding/92759/1 "2024-10-29T06:35:17Z")

</div>

I'm working with Node-RED and using the Tabulator component to display a table. I want to hide the "gender" column based on user input.

In my function node, I have this code:

```auto
msg.payload = {
    tbCmd: "hideColumn",
    tbArgs: ["gender"]
};
return msg;

```

that is my function node. i will give the full flow . if the user is admin it will hide the gender column otherwise it will hide the age column.

```auto
[
    {
        "id": "668ecdda037b4e29",
        "type": "function",
        "z": "346e27230dded336",
        "g": "dcfef50ab05d17e3",
        "name": "function 64",
        "func": "// msg.tbCmd = \"tbCreateTable\";\n// msg.tbInitObj = {\n// \theight:200,\n// \tdata:[\n// \t\t{id:1,text:\"Line 1\"},\n// \t\t{id:2,text:\"Line 2\"},\n// \t\t{id:3,text:\"Line 3\"}\n// \t],\n// \tcolumns:[\n// \t\t{title:\"Id\",field:\"id\",width:50,hozAlign:\"center\"},\n// \t\t{title:\"Text\",field:\"text\",width:200,hozAlign:\"left\",editor:\"input\"}\n// \t]\n// }\n\n// return msg;\n\nmsg.tbCmd = \"tbCreateTable\";\nmsg.tbInitObj = {\n height: 300, // Adjust the height as needed\n data: [\n {id: 1, name: \"Alice\", age: 25, gender: \"Female\", country: \"USA\"},\n {id: 2, name: \"Bob\", age: 30, gender: \"Male\", country: \"Canada\"},\n {id: 3, name: \"Charlie\", age: 35, gender: \"Male\", country: \"UK\"},\n {id: 4, name: \"Diana\", age: 28, gender: \"Female\", country: \"Australia\"}\n],\n columns: [\n {title: \"ID\", field: \"id\", width: 50, hozAlign: \"center\"},\n {title: \"Name\", field: \"name\", width: 150, hozAlign: \"left\", editor: \"input\"},\n {title: \"Age\", field: \"age\", width: 100, hozAlign: \"center\", editor: \"input\"},\n {\n title: \"Gender\",\n field: \"gender\",\n width: 100,\n hozAlign: \"center\",\n editor: \"select\",\n editorParams: {\n values: {\n \"Male\": \"Male\",\n \"Female\": \"Female\"\n }\n }\n },\n {title: \"Country\", field: \"country\", width: 150, hozAlign: \"left\", editor: \"input\"}\n],\n cellEdited: function(cell) {\n // This function will be called after a cell is edited\n console.log(\"Cell Edited:\", cell.getField(), \"New Value:\", cell.getValue());\n }\n};\n\nreturn msg;\n\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 255,
        "y": 60,
        "wires": [
            [
                "93bf13defe0bd934"
            ]
        ],
        "l": false
    }
]

```

The debug node shows that the payload is correct, but the "gender" column is still visible in the table.

Here’s a quick overview of my flow:

- **Function Node** : (Code above)
- **Debug Node** : Outputs `msg.payload`  
I’ve checked that the column name is correct, but it’s still not hiding.

Can anyone help me figure out why this is happening? Thanks!

---

<div class="post-metadata">

**Author:** ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)\
**Post date:** [29 October 2024 07:36 UTC](https://discourse.nodered.org/t/node-red-tabulator-column-not-hiding/92759/2 "2024-10-29T07:36:06Z")

</div>

Hi,  
The table is not constructed properly - you placed a function ( `cellEdited()` ) in the initialization object. Once the function is removed, `hideColumn` works.

I deliberately do not support functions within msg objects (while technically possible, it imposes a 'code injection' security risk).

You can register to the `cellEdited` event and get notifications (with before & after values) when cells are edited.

---

<div class="post-metadata">

**Author:** ![sys64738](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sys64738](https://discourse.nodered.org/u/sys64738)\
**Post date:** [29 October 2024 23:19 UTC](https://discourse.nodered.org/t/node-red-tabulator-column-not-hiding/92759/3 "2024-10-29T23:19:34Z")

</div>

Have you decided not to support functions in the table definition, such as custom formatter functions? I was hoping for a workaround. Custom formatters were often used in the dashboard-1.0 tabulator node (ui-table), as it was possible to include serialized functions in the tabulator object definition, for instance if you want to display table data with units without altering the data itself:

"formatter": "function(cell, formatterParams, onRendered) { const val = cell.getValue(); return val ? val + ' °C' : '';}"

Sometimes you want to keep numerical data strictly numerical when sorting or filtering. Is there a way to display data with units in the current version of ui-tabulator, without affecting the data itself? If you are reluctant to supporting formatter functions, maybe there's some other way displaying units could be supported, like the tbSetStyle command.

---

<div class="post-metadata">

**Author:** ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)\
**Post date:** [30 October 2024 12:44 UTC](https://discourse.nodered.org/t/node-red-tabulator-column-not-hiding/92759/4 "2024-10-30T12:44:56Z")

</div>

I fully realize the power & flexibility of Tabulator functions, such as custom formatters, and use them a lot myself.  
The `ui-tabulator` node was built, in the spirit of Node-RED, for low-code, "black-box" implementations. It is always possible (as I do many times) to instantiate Tabulator within a Node-RED `ui-template` node and access its API directly to unleash its full capabilities.

While Node-RED messages can include function properties, which can be sent & used across the flow, once a message is sent to a dashboard widget it is being stripped off any function properties. If I serialize/deserialize function code, it will immediately flag the node as insecure (our company's Node-RED flows are deployed at very big Telecom operators and are constantly scanned for security vulnerabilities).

I plan to add some formatting templates, like in `tbGroupBy` (where you can place `$field`, `$value` and `$count` tokens in a format template string).)

In the meantime, you can try using existing formatters (e.g. the **lookup** formatter, or **HTML** formatter with CSS logic).  
Or simply format the data update message itself, before it is sent to the `ui-tabulator` node.

---

<div class="post-metadata">

**Author:** ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)\
**Post date:** [3 November 2024 11:06 UTC](https://discourse.nodered.org/t/node-red-tabulator-column-not-hiding/92759/5 "2024-11-03T11:06:53Z")

</div>

I think I found a way to allow adding function attributes in a safe way. For now, I will add this in the next release as an experimental/undocumented feature. Of course, this will put responsibility on the user to provide valid function code.

---

<div class="post-metadata">

**Author:** ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)\
**Post date:** [24 November 2024 15:14 UTC](https://discourse.nodered.org/t/node-red-tabulator-column-not-hiding/92759/6 "2024-11-24T15:14:04Z")

</div>

`@omrid01/node-red-dashboard-2-table-tabulator` v0.6.0 has been released, and it now supports function attributes.

---

<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:** [22 February 2025 15:14 UTC](https://discourse.nodered.org/t/node-red-tabulator-column-not-hiding/92759/7 "2025-02-22T15:14:52Z")

</div>

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