An other easy example - how to get the row index is using the internal variable $index.
Try this flow:
[
{
"id": "dd090153.6381a",
"type": "debug",
"z": "dce8fa20.2e93c8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 610,
"y": 740,
"wires": []
},
{
"id": "149dc550.0ad30b",
"type": "inject",
"z": "dce8fa20.2e93c8",
"name": "",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "time",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 660,
"wires": [
[
"c3ceb6dd.40c6a8"
]
]
},
{
"id": "c3ceb6dd.40c6a8",
"type": "function",
"z": "dce8fa20.2e93c8",
"name": "",
"func": "msg.payload=[{sensor:\"sensor1\",battery:12.5,temp:21},{sensor:\"sensor2\",battery:13.5,temp:24}];\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 350,
"y": 680,
"wires": [
[
"582467cc.6326d8"
]
]
},
{
"id": "582467cc.6326d8",
"type": "ui_template",
"z": "dce8fa20.2e93c8",
"group": "de0e68e4.027ef8",
"name": "",
"order": 5,
"width": "0",
"height": "0",
"format": "<style>\n.main\n{\n height:400px;\n width:400px;\n background:dimgrey;\n \n}\n</style>\n<div class=\"main\">\n <table>\n <tr><th>Sensor</th><th>Battery</th><th>Temperature</th></tr>\n <tr ng-repeat=\"y in msg.payload\">\n <td>{{y.sensor}}</td><td>{{y.battery}}</td><td>{{y.temp}}</td>\n <td><input type=\"button\" ng-click=\"send({payload:$index,topic:'ok'})\">OK </td>\n\n\n</tr>\n</table>\n</div>",
"storeOutMessages": true,
"fwdInMessages": false,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 520,
"y": 660,
"wires": [
[
"dd090153.6381a",
"ed9e1613.c55b18"
]
]
},
{
"id": "e82de633.e648b8",
"type": "comment",
"z": "dce8fa20.2e93c8",
"name": "test8",
"info": "",
"x": 350,
"y": 580,
"wires": []
},
{
"id": "ed9e1613.c55b18",
"type": "delay",
"z": "dce8fa20.2e93c8",
"name": "",
"pauseType": "delay",
"timeout": "100",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"outputs": 1,
"x": 360,
"y": 740,
"wires": [
[
"c3ceb6dd.40c6a8"
]
]
},
{
"id": "de0e68e4.027ef8",
"type": "ui_group",
"name": "test8",
"tab": "2ce144dc.d7472c",
"order": 4,
"disp": true,
"width": "10",
"collapse": false
},
{
"id": "2ce144dc.d7472c",
"type": "ui_tab",
"name": "test",
"icon": "dashboard",
"order": 22,
"disabled": false,
"hidden": false
}
]
This will generate a small table with a button - but you can use any item with a click event:
Important is the internal $index variable which will be send in the payload:
ng-click="send({payload:$index,topic:'ok'})"
This will send you the row number as index in your payload back:
So in summary, add a ng-click in your cell, return either the index or a value of row resp. your value - and it should work.
So taking your code - this should work:
<div>
<table id="table" border="1">
<tbody>
<tr ng-repeat="row in msg.payload">
<td class="numeric" ng-click="send({payload:row})">{{row}}</td>
</tr>
</tbody>
</table>
</div>
If you combine it with a script function in the template node to change a visual feedback is another story. Extracting values of your row can be performed later on - if the payload contains the whole row and must not be performed within the template node.