Hi,
I want to create a table with a fixed number of rows to present some data. The data changes from time to time, so some updates to a table row must be made. I managed to store the entire data in a variable, empty the table, and send the updated data. However, I don't like this behavior, and I want to update only the modified row. Do you have any idea of how this can be achieved?
[
{
"id": "2ba7deac440e1960",
"type": "function",
"z": "2b18c57b69cd6210",
"name": "function 2",
"func": "\nlet a = new Array(17);\n\nlet tmp={\n _id:null,\n status:\"red\",\n note:\"---\"\n}\n\nfor(var i=0;i<17;i++){\n a[i]=JSON.parse(JSON.stringify(tmp));\n a[i]._id=i;\n}\nmsg.payload=a;\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 340,
"y": 280,
"wires": [
[
"2bc9c7cc438f2fe5"
]
]
},
{
"id": "3cb7e42beaf12746",
"type": "inject",
"z": "2b18c57b69cd6210",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 280,
"wires": [
[
"2ba7deac440e1960"
]
]
},
{
"id": "c069d93da2105b27",
"type": "function",
"z": "2b18c57b69cd6210",
"name": "function 3",
"func": "let tmp={\n id:1,\n status:\"blue\",\n}\n\nmsg.payload={\n \"command\": \"updateOrAddData\",\n \"arguments\":[\n {\n \"_id\": 5,\n \"status\": \"blue\",\n }\n ]\n}\n\nreturn msg;\n\n/*var id = flow.get(\"lastId\") || 0;\nif (id < 2) {\n node.error(\"use only if minimum of 2 Lines existing!\")\n return;\n}\n\nid = Math.floor(id / 2); //\nmsg.payload = {\n command: \"updateOrAddData\",\n arguments: [\n [\n {\n \"id\": id,\n \"timestamp\": msg.payload,\n \"text\": \"updateOrAddData (update) (#\" + id + \")\"\n }\n ]\n ],\n returnPromise: true\n}\nreturn msg;*/",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 360,
"y": 380,
"wires": [
[
"fbc51469412e3398",
"2bc9c7cc438f2fe5"
]
]
},
{
"id": "b1356aa9b5db4e1a",
"type": "inject",
"z": "2b18c57b69cd6210",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 380,
"wires": [
[
"c069d93da2105b27"
]
]
},
{
"id": "fbc51469412e3398",
"type": "debug",
"z": "2b18c57b69cd6210",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 620,
"y": 380,
"wires": []
},
{
"id": "2bc9c7cc438f2fe5",
"type": "ui_table",
"z": "2b18c57b69cd6210",
"group": "6330219bb2ab7ec9",
"name": "",
"order": 0,
"width": "14",
"height": "10",
"columns": [
{
"field": "_id",
"title": "id",
"width": "",
"align": "left",
"formatter": "plaintext",
"formatterParams": {
"target": "_blank"
}
},
{
"field": "status",
"title": "Status Cutie",
"width": "",
"align": "left",
"formatter": "color",
"formatterParams": {
"target": "_blank"
}
}
],
"outputs": 0,
"cts": false,
"x": 610,
"y": 280,
"wires": []
},
{
"id": "6330219bb2ab7ec9",
"type": "ui_group",
"name": "G1",
"tab": "e3950d42c787dcee",
"order": 1,
"disp": true,
"width": "14",
"collapse": false,
"className": ""
},
{
"id": "e3950d42c787dcee",
"type": "ui_tab",
"name": "MAIN",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]
Admin Edit: Removed extra backticks around flow, allowing it to be imported.