Ui-table Dashboard 2.0 row number not returned

Dear Community

Im using ui-table of Dashboard 2.0. There I have a table and I want to find out which row was clicked. This should be possible according the description, because its written the full row object is emitted. But thats not true, the column specified as "Row Number" is not part of the object. Doing Im something wrong or what is needed to get the row number, otherwise
it`s impossible to know which row was clicked.

Thanks
Chris

No it is not. If you give your table data an unique ID (or row number), then that would be returned, you do not need to display it. You would need to track/store this so you can append data.

Or you can search the data array for the id.

e.g.

[{"id":"fcd9ceaf8abf44e4","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"id\":1,\"test\":\"one\"},{\"id\":2,\"test\":\"two\"}]","payloadType":"json","x":210,"y":5680,"wires":[["7f4163ee549d9273"]]},{"id":"7f4163ee549d9273","type":"ui-table","z":"d1395164b4eec73e","group":"9d83cd8b3d5ee33c","name":"","label":"","order":1,"width":0,"height":0,"maxrows":0,"passthru":false,"autocols":false,"showSearch":true,"selectionType":"click","columns":[{"title":"","key":"test","keyType":"key","type":"text","width":"","align":"start"}],"mobileBreakpoint":"sm","mobileBreakpointType":"defaults","action":"replace","x":410,"y":5660,"wires":[["71dcd6fef6b08225"]]},{"id":"71dcd6fef6b08225","type":"debug","z":"d1395164b4eec73e","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":5660,"wires":[]},{"id":"9d83cd8b3d5ee33c","type":"ui-group","name":"Group1","page":"c694d0ebe0d2b702","width":"6","height":"1","order":1,"showTitle":true,"className":"","visible":"true","disabled":"false","groupType":"default"},{"id":"c694d0ebe0d2b702","type":"ui-page","name":"Page1","ui":"1805777f90e92057","path":"/page1","icon":"home","layout":"grid","theme":"a965ccfef139317a","breakpoints":[{"name":"Default","px":0,"cols":3},{"name":"Tablet","px":576,"cols":6},{"name":"Small Desktop","px":768,"cols":9},{"name":"Desktop","px":1024,"cols":12}],"order":1,"className":"","visible":true,"disabled":false},{"id":"1805777f90e92057","type":"ui-base","name":"dashboard ","path":"/dashboard","appIcon":"","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"titleBarStyle":"default","showReconnectNotification":false,"notificationDisplayTime":"5","showDisconnectNotification":false},{"id":"a965ccfef139317a","type":"ui-theme","name":"HN Theme","colors":{"surface":"#5c5c5c","primary":"#00fdff","bgPage":"#383838","groupBg":"#4f4f4f","groupOutline":"#858585"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]

Hello

Yes, of course if I give it to the rows.
I meant it's impossible from given data, even if there is a row number column.

It is not impossible.

As said you can search for the index.
e.g

[{"id":"fcd9ceaf8abf44e4","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"id\":1,\"test\":\"one\"},{\"id\":2,\"test\":\"two\"}]","payloadType":"json","x":210,"y":5680,"wires":[["31850bca664e6129"]]},{"id":"31850bca664e6129","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"table_data","pt":"flow","to":"payload","tot":"msg","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":5640,"wires":[["7f4163ee549d9273"]]},{"id":"7f4163ee549d9273","type":"ui-table","z":"d1395164b4eec73e","group":"9d83cd8b3d5ee33c","name":"","label":"","order":1,"width":0,"height":0,"maxrows":0,"passthru":false,"autocols":false,"showSearch":true,"selectionType":"click","columns":[{"title":"","key":"test","keyType":"key","type":"text","width":"","align":"start"}],"mobileBreakpoint":"sm","mobileBreakpointType":"defaults","action":"replace","x":410,"y":5660,"wires":[["1f3fe7ccad345bc7"]]},{"id":"1f3fe7ccad345bc7","type":"function","z":"d1395164b4eec73e","name":"function 1","func":"const table_data = flow.get(\"table_data\") ?? [];\nmsg.index = table_data.findIndex(item => item.id === msg.payload.id);\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":5660,"wires":[["71dcd6fef6b08225"]]},{"id":"71dcd6fef6b08225","type":"debug","z":"d1395164b4eec73e","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":780,"y":5660,"wires":[]},{"id":"9d83cd8b3d5ee33c","type":"ui-group","name":"Group1","page":"c694d0ebe0d2b702","width":"6","height":"1","order":1,"showTitle":true,"className":"","visible":"true","disabled":"false","groupType":"default"},{"id":"c694d0ebe0d2b702","type":"ui-page","name":"Page1","ui":"1805777f90e92057","path":"/page1","icon":"home","layout":"grid","theme":"a965ccfef139317a","breakpoints":[{"name":"Default","px":0,"cols":3},{"name":"Tablet","px":576,"cols":6},{"name":"Small Desktop","px":768,"cols":9},{"name":"Desktop","px":1024,"cols":12}],"order":1,"className":"","visible":true,"disabled":false},{"id":"1805777f90e92057","type":"ui-base","name":"dashboard ","path":"/dashboard","appIcon":"","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"titleBarStyle":"default","showReconnectNotification":false,"notificationDisplayTime":"5","showDisconnectNotification":false},{"id":"a965ccfef139317a","type":"ui-theme","name":"HN Theme","colors":{"surface":"#5c5c5c","primary":"#00fdff","bgPage":"#383838","groupBg":"#4f4f4f","groupOutline":"#858585"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]

If you store you data as an object, with the row id as the name the search would be easier. and very simple to convert to array for the table data.
e.g

[{"id":"652ed9d09e2e4642","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":5620,"wires":[["82f2e7efa09392b4"]]},{"id":"82f2e7efa09392b4","type":"function","z":"d1395164b4eec73e","name":"function 2","func":"msg.payload = Object.values(flow.get(\"table_data\")) ?? [];\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":260,"y":5620,"wires":[["7f4163ee549d9273"]]},{"id":"7f4163ee549d9273","type":"ui-table","z":"d1395164b4eec73e","group":"9d83cd8b3d5ee33c","name":"","label":"","order":1,"width":0,"height":0,"maxrows":0,"passthru":false,"autocols":false,"showSearch":true,"selectionType":"click","columns":[{"title":"","key":"test","keyType":"key","type":"text","width":"","align":"start"}],"mobileBreakpoint":"sm","mobileBreakpointType":"defaults","action":"replace","x":410,"y":5620,"wires":[["4cefb78652b86a57"]]},{"id":"4cefb78652b86a57","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"id","pt":"msg","to":"table_data[msg.payload.id].id","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":5620,"wires":[["71dcd6fef6b08225"]]},{"id":"71dcd6fef6b08225","type":"debug","z":"d1395164b4eec73e","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":780,"y":5620,"wires":[]},{"id":"fcd9ceaf8abf44e4","type":"inject","z":"d1395164b4eec73e","name":"initialise data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"1\":{\"id\":1,\"test\":\"one\"},\"2\":{\"id\":2,\"test\":\"two\"}}","payloadType":"json","x":210,"y":5560,"wires":[["31850bca664e6129"]]},{"id":"31850bca664e6129","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"table_data","pt":"flow","to":"payload","tot":"msg","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":5560,"wires":[[]]},{"id":"9d83cd8b3d5ee33c","type":"ui-group","name":"Group1","page":"c694d0ebe0d2b702","width":"6","height":"1","order":1,"showTitle":true,"className":"","visible":"true","disabled":"false","groupType":"default"},{"id":"c694d0ebe0d2b702","type":"ui-page","name":"Page1","ui":"1805777f90e92057","path":"/page1","icon":"home","layout":"grid","theme":"a965ccfef139317a","breakpoints":[{"name":"Default","px":0,"cols":3},{"name":"Tablet","px":576,"cols":6},{"name":"Small Desktop","px":768,"cols":9},{"name":"Desktop","px":1024,"cols":12}],"order":1,"className":"","visible":true,"disabled":false},{"id":"1805777f90e92057","type":"ui-base","name":"dashboard ","path":"/dashboard","appIcon":"","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"titleBarStyle":"default","showReconnectNotification":false,"notificationDisplayTime":"5","showDisconnectNotification":false},{"id":"a965ccfef139317a","type":"ui-theme","name":"HN Theme","colors":{"surface":"#5c5c5c","primary":"#00fdff","bgPage":"#383838","groupBg":"#4f4f4f","groupOutline":"#858585"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]

You also have the option to use @omrid01/node-red-dashboard-2-table-tabulator, which enables to register for wide range of click & double-click notifications, sent with associated table/row/cell data

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.