# Get data from ui\_table

**URL:** <https://discourse.nodered.org/t/get-data-from-ui-table/41440>\
**Category:** Dashboard\
**Created:** [22 February 2021 16:01 UTC](https://discourse.nodered.org/t/get-data-from-ui-table/41440 "2021-02-22T16:01:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aitor](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aitor/32/97363_2.png) [@aitor](https://discourse.nodered.org/u/aitor)\
**Post date:** [22 February 2021 16:01 UTC](https://discourse.nodered.org/t/get-data-from-ui-table/41440/1 "2021-02-22T16:01:35Z")

</div>

Hi there,

I am trying to pass the data displayed in the ui\_table to the payload.  
I have tried to use tabulator's table.getData() command but I didn't manage to get any result in the payload.

I am sending the command this way:

msg.payload={  
command:"getData",  
arguments: ,  
}

Any help about this issue?

Thanks in advance,  
Aitor

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 February 2021 18:20 UTC](https://discourse.nodered.org/t/get-data-from-ui-table/41440/2 "2021-02-22T18:20:54Z")

</div>

Have you taken a look at th examples for that node?

I'm assuming you want to return a single row and not the entire table (since you actually pass add the data into the ui-table node in the first place). Have you ckecked off the 'Send data on click` option?

---

<div class="post-metadata">

**Author:** ![aitor](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aitor/32/97363_2.png) [@aitor](https://discourse.nodered.org/u/aitor)\
**Post date:** [23 February 2021 07:19 UTC](https://discourse.nodered.org/t/get-data-from-ui-table/41440/3 "2021-02-23T07:19:03Z")

</div>

Hi there, thanks for responding.

Yes, actually I tested the flows of the examples on Christian's github. Following the examples I can add, clear rows etc.  
I also enabled 'send data on click' and this sends be back the row I selected. However I wanted to have back the entire table, any clues about how can it be done?

Thanks,  
Aitor

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 February 2021 08:16 UTC](https://discourse.nodered.org/t/get-data-from-ui-table/41440/4 "2021-02-23T08:16:14Z")

</div>

@Christian-Me I'm at a loss 😧 have you any ideas?

---

<div class="post-metadata">

**Author:** ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)\
**Post date:** [23 February 2021 17:14 UTC](https://discourse.nodered.org/t/get-data-from-ui-table/41440/5 "2021-02-23T17:14:44Z")

</div>

Hi ... I don't think there is a command available to "export" the hole table content.

I use my ui-table handler subflow to take care of all the tasks around ui-table.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/1/61b219610915f1eb1873e463b0487af959f1bb11.png)

it holds a copy of your table-data, tabel edits and table config (useful for replay on browser reconnects)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f6ea926faee1db1e0361af368a8c4ef80e064b86.png)

and you can export the table context too ... (merged tableEdit into tableData)

this is the latest Version:  
[https://flows.nodered.org/flow/35d0480ce9151b2a722fa9d185a37825](https://flows.nodered.org/flow/35d0480ce9151b2a722fa9d185a37825)

You can find it in my homie-device-table and syslog-server. (older versions)

a `msg.payload.command="getTable"` should give you the table array on the second output

The doc (help tab) is not 100% up to date but should do the task

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/1/21d9a88697e936194a96efe583a6d5afa4a367f8.png)

---

<div class="post-metadata">

**Author:** ![aitor](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aitor/32/97363_2.png) [@aitor](https://discourse.nodered.org/u/aitor)\
**Post date:** [24 February 2021 09:02 UTC](https://discourse.nodered.org/t/get-data-from-ui-table/41440/6 "2021-02-24T09:02:12Z")

</div>

Hi Christian,

Nice solution yours!

However, it was not suitable for me since I wanted to get he data that was directly written in the table, so I could not save that input in your handler's buffer.  
I came up with an alternative that is suitable for my application. Whenever I select the row of the table, the table returns which is the currently selected row. And once the data of the row has been edited it also returns a 'cellEditedCallback'. So knowing which was the latest selected row and the edited value I can update my table buffer with the correspondig new value. This way, I update individually each row whenever it has been edited.

I'm leaving solution here:

```auto
[{"id":"dd57457f.f1874","type":"function","z":"dbb19b25.93c07","name":"Define Table","func":"value_list = context.flow.get(\"values_list\")\ncolumns_list = context.flow.get(\"column_list\")\ntable = []\n\n// Define Content\nfor (i=0; i<columns_list.length;i++){\n column_name = columns_list[i]\n value = value_list[i]\n table[i]=Object.assign({ENTRY_NAME:column_name,VALUE:value})\n}\nmsg.payload = table\ncontext.flow.set(\"table\",table)\n\nreturn msg;","outputs":1,"noerr":0,"x":190,"y":968,"wires":[["d933ab86.c1e148"]]},{"id":"d933ab86.c1e148","type":"function","z":"dbb19b25.93c07","name":"Table UI","func":"//Define Table Control\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\":\"Entry Name\",\"field\":\"ENTRY_NAME\",\"align\":\"left\"},\n {\"formatterParams\":{\"target\":\"_blank\"},\"title\":\"Value\",\"field\":\"VALUE\",\"align\":\"left\", \"editor\":\"input\"},\n\n],\n \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}\nreturn msg;","outputs":1,"noerr":0,"x":348,"y":968,"wires":[["38f4ab6d.1e5e34"]]},{"id":"38f4ab6d.1e5e34","type":"ui_table","z":"dbb19b25.93c07","group":"ff5ded58.80b7b8","name":"","order":1,"width":24,"height":"9","columns":[{"field":"ENTRY_NAME","title":"Entry Name","width":"","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"VALUE","title":"Value","width":"","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}}],"outputs":1,"cts":true,"x":490,"y":968,"wires":[["1ce60da5.e86912"]]},{"id":"1ce60da5.e86912","type":"function","z":"dbb19b25.93c07","name":"Define Selected Entry","func":"if (msg.topic === 'VALUE'){\n context.flow.set(\"selected_entry\",msg.payload.ENTRY_NAME)\n}\nreturn msg;","outputs":1,"noerr":0,"x":668,"y":968,"wires":[["2d75fdf9.c1754a"]]},{"id":"2d75fdf9.c1754a","type":"function","z":"dbb19b25.93c07","name":"Update Data","func":"// Update Table Data Buffer\nselected_entry = context.flow.get(\"selected_entry\")\ntable = context.flow.get(\"table\")\n\nif (msg.ui_control.callback === 'cellEdited'){\n new_val = msg.ui_control.changes.newValue\n for (i=0; i<table.length;i++){\n if(table[i].ENTRY_NAME === selected_entry){\n table[i].VALUE = new_val\n }\n } \n}\nreturn msg;","outputs":1,"noerr":0,"x":862,"y":968,"wires":[[]]},{"id":"ff5ded58.80b7b8","type":"ui_group","z":"","name":"Recipe Table","tab":"64e5b49a.2728cc","order":3,"disp":false,"width":"24","collapse":false},{"id":"64e5b49a.2728cc","type":"ui_tab","z":"","name":"Recipe Management","icon":"subject","order":3,"disabled":false,"hidden":true}]

```

Thanks for your help! @zenofmud @Christian-Me

---

<div class="post-metadata">

**Author:** ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)\
**Post date:** [8 March 2021 17:14 UTC](https://discourse.nodered.org/t/get-data-from-ui-table/41440/7 "2021-03-08T17:14:20Z")

</div>

Great to hear that you found a alternative solution.

Sorry I could not check out your flow, but I think I do the same, perhaps a little bit different 😉

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 April 2021 17:14 UTC](https://discourse.nodered.org/t/get-data-from-ui-table/41440/8 "2021-04-07T17:14:56Z")

</div>

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