Hello, I'm new to Node-Red and with gaps in javascript, I'm studying node ui-table. I have implemented the ability to change a value in a cell, but I can't recover the typed change. When I try to retrieve the value of msg.ui_control.changes.newValue I get the following error: TypeError: Cannot read properties of undefined (reading 'changes').
Help in solving the problem is welcome.
[
{
"id": "591cd40f23ae1233",
"type": "tab",
"label": "Flow 5",
"disabled": false,
"info": "",
"env": []
},
{
"id": "0c95f6e04aa2191d",
"type": "inject",
"z": "591cd40f23ae1233",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 100,
"y": 60,
"wires": [
[
"6b11cbd3bff5feb5"
]
]
},
{
"id": "77beef291e58df96",
"type": "mysql",
"z": "591cd40f23ae1233",
"mydb": "fded45f38ac71b78",
"name": "",
"x": 120,
"y": 160,
"wires": [
[
"c3e82eca2cd3e823"
]
]
},
{
"id": "c3e82eca2cd3e823",
"type": "function",
"z": "591cd40f23ae1233",
"name": "function 28",
"func": "var output = [];\nfor (var i = 0; i < msg.payload.length; i++) {\n var row = {};\n row.id = msg.payload[i].id;\n row.DATA = msg.payload[i].DATA;\n row.NAME = msg.payload[i].NAME;\n row.AGE = msg.payload[i].AGE;\n row.COLORE = msg.payload[i].COLORE;\n output.push(row);\n}\n\nmsg.payload = output;\nmsg.ui_control = {\n \"tabulator\": {\n \"columnResized\": \"function(column){var newColumn = { field: column._column.field, visible: column._column.visible, width: column._column.width, widthFixed: column._column.widthFixed, widthStyled: column._column.widthStyled }; this.send({topic:this.config.topic,ui_control:{callback:'columnResized',columnWidths:newColumn}}); }\",\n \"columnMoved\": \"function(column, columns){ var newColumns=[]; columns.forEach(function (column) { newColumns.push({'field': column._column.field}); }); this.send({topic:this.config.topic,ui_control:{callback:'columnMoved',columns:newColumns}}); }\",\n \"groupHeader\": \"function (value, count, data, group) {return value + \\\"<span style='color:#d00; margin-left:10px;'>(\\\" + count + \\\" Termostat\\\"+((count>1) ? \\\"e\\\" : \\\"\\\") + \\\")</span>\\\";}\",\n \"columns\": [\n { \"formatterParams\": { \"target\": \"_blank\" }, \"title\": \"Id\", \"field\": \"id\", \"width\": 100, \"align\": \"center\" },\n { \"formatterParams\": { \"target\": \"_blank\" }, \"title\": \"Data\", \"field\": \"DATA\", \"width\": 100, \"align\": \"center\" },\n { \"formatterParams\": { \"target\": \"_blank\" }, \"title\": \"Nome\", \"field\": \"NAME\", \"width\": 100, \"align\": \"center\" },\n { \"formatterParams\": { \"target\": \"_blank\" }, \"title\": \"Anni\", \"field\": \"AGE\", \"width\": 100, \"editor\": \"input\" },\n { \"formatterParams\": { \"target\": \"_blank\" }, \"title\": \"Colore\", \"field\": \"COLORE\", \"width\": 100, \"align\": \"center\" },\n ],\n //\"cellEdited\":\"function(cell){this.send({ui_control:{callback:'cellEdited'},payload:cell.getValue(),oldValue:cell.getOldValue(),field:cell.getColumn().getField(),id:cell.getRow().getCell('id').getValue()}); }\",\n \"cellEdited\": \"function(cell){var change = {newValue:cell.getValue()};this.send({topic:this.config.topic,ui_control:{callback:'cellEdited',changes:change}});}\",\n \"layout\": \"fitColumns\",\n \"movableColumns\": true,\n \"groupBy\": \"\"\n },\n \"customHeight\": 12\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 160,
"wires": [
[
"5048d05c2c8d3979"
]
]
},
{
"id": "6b11cbd3bff5feb5",
"type": "function",
"z": "591cd40f23ae1233",
"name": "function 29",
"func": "var select = \"SELECT ID AS id, DATA, NAME, AGE, COLORE\" +\n \" FROM TEST\" +\n \" ORDER BY STR_TO_DATE(DATA, '%e-%c-%Y') ASC;\";\nmsg.topic = select;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 280,
"y": 60,
"wires": [
[
"77beef291e58df96"
]
]
},
{
"id": "5048d05c2c8d3979",
"type": "ui_table",
"z": "591cd40f23ae1233",
"group": "b703f34de6178e44",
"name": "tabella",
"order": 1,
"width": "14",
"height": "7",
"columns": [],
"outputs": 1,
"cts": true,
"x": 450,
"y": 180,
"wires": [
[
"d74bce060ac86841",
"ac5ffe1704e21f53"
]
]
},
{
"id": "d74bce060ac86841",
"type": "function",
"z": "591cd40f23ae1233",
"name": "function 30",
"func": "let a = Object(msg.payload);\nlet b = a.id;\nlet c = msg.topic;\nlet d = msg.ui_control.changes.newValue;\n\nmsg.payload = {\n idd: b,\n campo: c,\n// nuovo: d,\n};\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 650,
"y": 180,
"wires": [
[
"cf4ad65dd1644bf6"
]
]
},
{
"id": "ac5ffe1704e21f53",
"type": "debug",
"z": "591cd40f23ae1233",
"name": "debug 84",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 690,
"y": 60,
"wires": []
},
{
"id": "cf4ad65dd1644bf6",
"type": "debug",
"z": "591cd40f23ae1233",
"name": "debug 85",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 800,
"y": 180,
"wires": []
},
{
"id": "fded45f38ac71b78",
"type": "MySQLdatabase",
"name": "",
"host": "172.18.0.11",
"port": "3306",
"db": "node-red",
"tz": "",
"charset": "UTF8"
},
{
"id": "b703f34de6178e44",
"type": "ui_group",
"name": "Group 1",
"tab": "9dd218d0a686108d",
"order": 1,
"disp": true,
"width": 20
},
{
"id": "9dd218d0a686108d",
"type": "ui_tab",
"name": "Test",
"icon": "dashboard",
"order": 3,
"disabled": false,
"hidden": false
}
]