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:
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.
[
{
"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!