Followup Question
OK I have the column high lite color working as above.
Q - How do I send a second search term and row highlight color to the ui_table?
Now, when I send the second search term and color, the first color is removed.
I am following the same method as used in the ui-table example. I have included the example flow, with my added functions below.
Alan
[
{
"id": "2e6a6379.742abc",
"type": "ui_table",
"z": "569288c052d73ac8",
"group": "ff9fdb9a.7da098",
"name": "testTable",
"order": 6,
"width": "8",
"height": 5,
"columns": [
{
"field": "rowNumber",
"title": "Row Number 1",
"width": "",
"align": "left",
"formatter": "rownum",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "textValue",
"title": "Text",
"width": "",
"align": "left",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "numberValue",
"title": "Number",
"width": "",
"align": "left",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
}
],
"outputs": 1,
"cts": true,
"x": 1140,
"y": 2200,
"wires": [
[
"1c377ea0.5801e1"
]
]
},
{
"id": "16664cef.5b26b3",
"type": "function",
"z": "569288c052d73ac8",
"name": "table paramter",
"func": "msg.ui_control = {tabulator:{}};\n\n//workaround that buttos can`t deliver empty strings\nif (msg.payload.hasOwnProperty('payload')) {\n msg.payload=msg.payload.payload;\n}\n\nmsg.ui_control.tabulator[msg.topic]=msg.payload;\ndelete msg.topic;\nmsg.payload=null;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 922,
"y": 2489,
"wires": [
[
"2e6a6379.742abc",
"b8d75d24.6cbed"
]
]
},
{
"id": "b8d75d24.6cbed",
"type": "debug",
"z": "569288c052d73ac8",
"name": "table input",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "ui_control",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1150,
"y": 2489,
"wires": []
},
{
"id": "1c377ea0.5801e1",
"type": "debug",
"z": "569288c052d73ac8",
"name": "table output",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 1303,
"y": 2200,
"wires": []
},
{
"id": "b15c31a9.af37c",
"type": "ui_switch",
"z": "569288c052d73ac8",
"name": "selectable",
"label": "selectable",
"tooltip": "",
"group": "ff9fdb9a.7da098",
"order": 7,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "selectable",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"x": 562,
"y": 2285,
"wires": [
[
"16664cef.5b26b3"
]
]
},
{
"id": "75207e8d.c54d4",
"type": "ui_switch",
"z": "569288c052d73ac8",
"name": "movableColumns",
"label": "movableColumns",
"tooltip": "",
"group": "ff9fdb9a.7da098",
"order": 8,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "movableColumns",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"x": 592,
"y": 2336,
"wires": [
[
"16664cef.5b26b3"
]
]
},
{
"id": "c585e7a1.dfc648",
"type": "ui_button",
"z": "569288c052d73ac8",
"name": "",
"group": "ff9fdb9a.7da098",
"order": 9,
"width": "4",
"height": "1",
"passthru": false,
"label": "Format Numbers > 100",
"tooltip": "using a rowFormatter callback function",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "function(row){ if(row.getData().numberValue>100){ row.getElement().style.backgroundColor = \"#A6A6DF\"; } },",
"payloadType": "str",
"topic": "rowFormatter",
"topicType": "str",
"x": 612,
"y": 2472,
"wires": [
[
"16664cef.5b26b3",
"b2b801ac9636df9c"
]
]
},
{
"id": "f178c6fe.710ef8",
"type": "ui_button",
"z": "569288c052d73ac8",
"name": "",
"group": "ff9fdb9a.7da098",
"order": 5,
"width": 0,
"height": 0,
"passthru": false,
"label": "Fill demo data",
"tooltip": "",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "[{\"textValue\":\"Line #1\",\"numberValue\":123.12},{\"textValue\":\"Line #2\",\"numberValue\":100},{\"textValue\":\"Line #3\",\"numberValue\":50}]",
"payloadType": "json",
"topic": "rowFormatter",
"x": 582,
"y": 2200,
"wires": [
[
"2e6a6379.742abc"
]
]
},
{
"id": "2403f929.df4006",
"type": "ui_button",
"z": "569288c052d73ac8",
"name": "",
"group": "ff9fdb9a.7da098",
"order": 11,
"width": "4",
"height": "1",
"passthru": false,
"label": "inject Tooltips callback",
"tooltip": "cell.getColumn().getField() + \" - \" + cell.getValue();",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "function(cell){return cell.getColumn().getField() + \" - \" + cell.getValue(); },",
"payloadType": "str",
"topic": "tooltips",
"x": 602,
"y": 2574,
"wires": [
[
"16664cef.5b26b3"
]
]
},
{
"id": "f6c68c45.58003",
"type": "ui_button",
"z": "569288c052d73ac8",
"name": "",
"group": "ff9fdb9a.7da098",
"order": 12,
"width": "4",
"height": "1",
"passthru": false,
"label": "clear Tooltips callback",
"tooltip": "empty string is not possible! so use a single space",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "{\"payload\":\"\"}",
"payloadType": "json",
"topic": "tooltips",
"x": 602,
"y": 2608,
"wires": [
[
"16664cef.5b26b3"
]
]
},
{
"id": "d2b29dda.60a5a",
"type": "ui_button",
"z": "569288c052d73ac8",
"name": "",
"group": "ff9fdb9a.7da098",
"order": 13,
"width": "4",
"height": "1",
"passthru": false,
"label": "reformat Number column",
"tooltip": "inject additional paramters to numberValue column",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "[{\"field\":\"numberValue\",\"formatterParams\":{\"min\":0,\"max\":200,\"legend\":\"function (value) { if (value<100) return \\\"<span style='color:#FF0000;'>\\\"+value+\\\"</span>\\\"; else return \\\"<span style='color:#000000;'>\\\"+value+\\\"</span>\\\"; }\",\"legendAlign\":\"center\"},\"formatter\":\"progress\",\"topCalc\":\"function(values, data, calcParams){ var total = 0; var calc = 0; var count = 0; data.forEach(value => { total+=Number(value.numberValue); count++; }); if (count>0) calc=(total/count).toFixed(2); return `${calc} (avg)`; }\",\"headerTooltip\":\"avarage\"}]",
"payloadType": "json",
"topic": "columns",
"x": 612,
"y": 2676,
"wires": [
[
"16664cef.5b26b3"
]
]
},
{
"id": "7b6490b3.cd9c7",
"type": "function",
"z": "569288c052d73ac8",
"name": "callback function(s)",
"func": "// how to use the editor to write callback functions\n// DO NOT wire this into your flow!\n// copy / paste \"function( ... }\" into the correct calback parameter\n// use the \"debugger\" statement to debug your callback inside your browser\n\nvar topCalc = function(values, data, calcParams){\n var total = 0;\n var calc = 0;\n var count = 0;\n data.forEach(value => {\n total+=Number(value.numberValue);\n count++;\n });\n if (count>0) calc=(total/count).toFixed(2);\n return `${calc} (avg)`;\n}\n\nvar legend = function (value) {\n if (value<100) return \"<span style='color:#FF0000;'>\"+value+\"</span>\";\n else return \"<span style='color:#000000;'>\"+value+\"</span>\"; \n}",
"outputs": 1,
"noerr": 0,
"x": 932,
"y": 2608,
"wires": [
[]
]
},
{
"id": "91506d4b.4956a",
"type": "comment",
"z": "569288c052d73ac8",
"name": "Intentionally not wired into the flow!",
"info": "use the editor to write callback functions\n\nDO NOT wire this into your flow!\n\ncopy / paste `function( ... }` into the correct calback parameter\nuse the `debugger` statement to debug your callback inside your browser\n",
"x": 982,
"y": 2574,
"wires": []
},
{
"id": "732afcea.f728f4",
"type": "ui_button",
"z": "569288c052d73ac8",
"name": "",
"group": "ff9fdb9a.7da098",
"order": 14,
"width": "4",
"height": "1",
"passthru": false,
"label": "reset Number column",
"tooltip": "inject additional paramters to numberValue column",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "[{\"field\":\"numberValue\",\"formatter\":\"plainText\",\"topCalc\":\"\",\"headerTooltip\":\"\"}]",
"payloadType": "json",
"topic": "columns",
"x": 602,
"y": 2710,
"wires": [
[
"16664cef.5b26b3"
]
]
},
{
"id": "89cca7ea.7fc998",
"type": "ui_button",
"z": "569288c052d73ac8",
"name": "",
"group": "ff9fdb9a.7da098",
"order": 15,
"width": "4",
"height": "1",
"passthru": false,
"label": "add/show id column",
"tooltip": "add a new column",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "[{\"field\":\"id\",\"title\":\"id\",\"visible\":true,\"formatter\":\"plainText\"}]",
"payloadType": "json",
"topic": "columns",
"x": 602,
"y": 2778,
"wires": [
[
"16664cef.5b26b3"
]
]
},
{
"id": "32a3c4ad.1b85fc",
"type": "ui_button",
"z": "569288c052d73ac8",
"name": "",
"group": "ff9fdb9a.7da098",
"order": 16,
"width": "4",
"height": "1",
"passthru": false,
"label": "hide id column",
"tooltip": "hide id column (it is not possible to delete a existing column definition)",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "[{\"field\":\"id\",\"title\":\"id\",\"visible\":false,\"formatter\":\"plainText\"}]",
"payloadType": "json",
"topic": "columns",
"x": 582,
"y": 2812,
"wires": [
[
"16664cef.5b26b3"
]
]
},
{
"id": "25247f4b.cc7ec",
"type": "inject",
"z": "569288c052d73ac8",
"name": "",
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "true",
"payloadType": "bool",
"x": 416,
"y": 2336,
"wires": [
[
"75207e8d.c54d4",
"bd3fd382.a2aa9"
]
]
},
{
"id": "18ed8d27.bf00a3",
"type": "ui_button",
"z": "569288c052d73ac8",
"name": "",
"group": "ff9fdb9a.7da098",
"order": 10,
"width": "4",
"height": "1",
"passthru": false,
"label": "reset Numbers > 100",
"tooltip": "using a rowFormatter callback function",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"payload": "{\"payload\":\"\"}",
"payloadType": "json",
"topic": "rowFormatter",
"topicType": "str",
"x": 602,
"y": 2506,
"wires": [
[
"16664cef.5b26b3",
"b2b801ac9636df9c"
]
]
},
{
"id": "bd3fd382.a2aa9",
"type": "ui_switch",
"z": "569288c052d73ac8",
"name": "headerVisible",
"label": "headerVisible",
"tooltip": "",
"group": "ff9fdb9a.7da098",
"order": 7,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "headerVisible",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "",
"x": 582,
"y": 2387,
"wires": [
[
"16664cef.5b26b3"
]
]
},
{
"id": "b2b801ac9636df9c",
"type": "debug",
"z": "569288c052d73ac8",
"name": "debug 419",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 920,
"y": 2360,
"wires": []
},
{
"id": "53eb3820bc2480e5",
"type": "function",
"z": "569288c052d73ac8",
"name": "function 27",
"func": "\n// Check if row.getData().numberValue is greater than 100\nif (msg.row && msg.row.getData().numberValue > 100) {\n // Set the background color of row.getElement()\n msg.row.getElement().style.backgroundColor = \"#A6A6DF\";\n\n // Create a string representation of the result\n msg.payload = \"NumberValue is greater than 100\";\n} else {\n msg.payload = \"NumberValue is not greater than 100\";\n}\n\n// Return the modified msg object\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1030,
"y": 2900,
"wires": [
[
"16664cef.5b26b3"
]
]
},
{
"id": "dea0f795461039e1",
"type": "inject",
"z": "569288c052d73ac8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 850,
"y": 2880,
"wires": [
[
"53eb3820bc2480e5"
]
]
},
{
"id": "f451b66417a5745c",
"type": "function",
"z": "569288c052d73ac8",
"name": "Set Background",
"func": "\n\n\nlet search_value = \"Line #1\";\nlet row_property = \"textValue\";\nlet color = \"blue\"; \n\nmsg.payload = `function(row){\n if (row.getData().${row_property} === \"${search_value}\") {\n row.getElement().style.backgroundColor = \"${color}\";\n }\n}`;\n\nmsg.topic = \"rowFormatter\";\n\nreturn msg;\n\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1340,
"y": 2660,
"wires": [
[
"76d1918126ac0f29",
"16664cef.5b26b3"
]
]
},
{
"id": "d58cacbe28fde723",
"type": "inject",
"z": "569288c052d73ac8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "trigger",
"payloadType": "str",
"x": 1170,
"y": 2660,
"wires": [
[
"f451b66417a5745c"
]
]
},
{
"id": "76d1918126ac0f29",
"type": "debug",
"z": "569288c052d73ac8",
"name": "debug 420",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1560,
"y": 2660,
"wires": []
},
{
"id": "485d98d42ed3b072",
"type": "function",
"z": "569288c052d73ac8",
"name": "function 29",
"func": "\n\n\nlet search_value = \"Line #3\";\nlet row_property = \"textValue\"; \n\nmsg.payload = `function(row){\n if (row.getData().${row_property} === \"${search_value}\") {\n row.getElement().style.backgroundColor = \"#A6A6DF\";\n }\n}`;\n\nmsg.topic = \"rowFormatter\";\n\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1370,
"y": 2560,
"wires": [
[]
]
},
{
"id": "bac3f29f25577c66",
"type": "inject",
"z": "569288c052d73ac8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 1230,
"y": 2760,
"wires": [
[
"14ae924053e48278"
]
]
},
{
"id": "12cf93c9b3bde1ba",
"type": "debug",
"z": "569288c052d73ac8",
"name": "debug 421",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1670,
"y": 2760,
"wires": []
},
{
"id": "14ae924053e48278",
"type": "function",
"z": "569288c052d73ac8",
"name": "Clear Hi Light",
"func": "\n\nmsg.payload = {\"payload\": \"\"};\n\nmsg.topic = \"rowFormatter\"\n\n\nreturn msg;\n\n\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1430,
"y": 2760,
"wires": [
[
"12cf93c9b3bde1ba",
"16664cef.5b26b3"
]
]
},
{
"id": "ff9fdb9a.7da098",
"type": "ui_group",
"name": "TEST",
"tab": "7dcc246f.ee661c",
"order": 1,
"disp": false,
"width": "8",
"collapse": false
},
{
"id": "7dcc246f.ee661c",
"type": "ui_tab",
"name": "TEST",
"icon": "dashboard",
"order": 12,
"disabled": false,
"hidden": false
}
]