# Display table data from sqlite

**URL:** <https://discourse.nodered.org/t/display-table-data-from-sqlite/50896>\
**Category:** Dashboard\
**Created:** [11 September 2021 18:54 UTC](https://discourse.nodered.org/t/display-table-data-from-sqlite/50896 "2021-09-11T18:54:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbartling](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bbartling](https://discourse.nodered.org/u/bbartling)\
**Post date:** [11 September 2021 18:54 UTC](https://discourse.nodered.org/t/display-table-data-from-sqlite/50896/1 "2021-09-11T18:54:17Z")

</div>

I am tinkering around with an sqlite query which is working but how can I roll this data up onto a table to view through the ui?

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/771d9d332e5e1c9c377bf4e3864354ef6abc3468.png)

On the template node does this look right?

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

```auto
<table style="width:100%">
  <tr>
    <th>Index</th> 
    <th>Object_Name</th>
    <th>Object_Type</th> 
    <th>Object_ID</th>
    <th>Device_ID</th>
  </tr>
  <tr ng-repeat="x in msg.payload | limitTo:200">
    <td>{{msg.payload[$index].index}}</td>
    <td>{{msg.payload[$index].object_names}}</td>
    <td>{{msg.payload[$index].object_type}}</td> 
    <td>{{msg.payload[$index].object_id}}</td>
    <td>{{msg.payload[$index].device_id}}</td>
  </tr>
</table>

```

The error that pops up is a group name error:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/285c586a492a3e5e1806c4bccac1e9b81f33664e.png)

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [11 September 2021 19:03 UTC](https://discourse.nodered.org/t/display-table-data-from-sqlite/50896/2 "2021-09-11T19:03:47Z")

</div>

Hello .. if you hover over the root of the array db result (in the Debug tab) you'll get a Copy value icon.  
Copy and paste using the **\< / \>** icon in a post, to have some sample data to test an example.

You dont need to use `msg.payload` again in the `<td>` since each element in the `msg.payload` array .. you named `x`. So it could just be

```auto
<tr ng-repeat="x in msg.payload | limitTo:200">
    <td>{{x.index}}</td>
    <td>{{x.object_names}}</td>
    <td>{{x.object_type}}</td> 
    <td>{{x.object_id}}</td>
    <td>{{x.device_id}}</td>
  </tr>

```

---

<div class="post-metadata">

**Author:** ![bbartling](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bbartling](https://discourse.nodered.org/u/bbartling)\
**Post date:** [11 September 2021 19:08 UTC](https://discourse.nodered.org/t/display-table-data-from-sqlite/50896/3 "2021-09-11T19:08:06Z")

</div>

Ok I think I understand sorry sort of new to node red. This is the copy paste:

`[{"index":10,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":23},{"index":10,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":24},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":25},{"index":34,"object_names":"Space Temperature Setpoint BAS","object_type":"analogValue","object_id":27,"device_id":12026},{"index":10,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":27},{"index":33,"object_names":"Space Temperature Setpoint BAS","object_type":"analogValue","object_id":27,"device_id":12028},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":29},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":30},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":31},{"index":34,"object_names":"Space Temperature Setpoint BAS","object_type":"analogValue","object_id":27,"device_id":12032},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":6},{"index":34,"object_names":"Space Temperature Setpoint BAS","object_type":"analogValue","object_id":27,"device_id":12033},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":7},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":34},{"index":10,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":8},{"index":33,"object_names":"Space Temperature Setpoint BAS","object_type":"analogValue","object_id":27,"device_id":12035},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":9},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":36},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":10},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":11},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":13},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":14},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":15},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":16},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":19},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":20},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":21},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":37},{"index":9,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":38},{"index":10,"object_names":"ZN-SP","object_type":"analogValue","object_id":1103,"device_id":39}]`

---

<div class="post-metadata">

**Author:** ![bbartling](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bbartling](https://discourse.nodered.org/u/bbartling)\
**Post date:** [11 September 2021 19:12 UTC](https://discourse.nodered.org/t/display-table-data-from-sqlite/50896/4 "2021-09-11T19:12:54Z")

</div>

This message also pops up:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a974a92d9aeed97576c5710133c40fe870523bf1.png)

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [11 September 2021 19:20 UTC](https://discourse.nodered.org/t/display-table-data-from-sqlite/50896/5 "2021-09-11T19:20:48Z")

</div>

Double click on the ui\_template node and see what is not configured.  
it should have a red outline / border around either the Group or Tab the ui node should belong.

**Test Flow** ( Ctrl-I to import )

```auto
[{"id":"79e9853a5758d7f0","type":"inject","z":"4895ea10b4ee9ead","name":"DB Data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"[{\"index\":10,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":23},{\"index\":10,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":24},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":25},{\"index\":34,\"object_names\":\"Space Temperature Setpoint BAS\",\"object_type\":\"analogValue\",\"object_id\":27,\"device_id\":12026},{\"index\":10,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":27},{\"index\":33,\"object_names\":\"Space Temperature Setpoint BAS\",\"object_type\":\"analogValue\",\"object_id\":27,\"device_id\":12028},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":29},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":30},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":31},{\"index\":34,\"object_names\":\"Space Temperature Setpoint BAS\",\"object_type\":\"analogValue\",\"object_id\":27,\"device_id\":12032},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":6},{\"index\":34,\"object_names\":\"Space Temperature Setpoint BAS\",\"object_type\":\"analogValue\",\"object_id\":27,\"device_id\":12033},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":7},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":34},{\"index\":10,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":8},{\"index\":33,\"object_names\":\"Space Temperature Setpoint BAS\",\"object_type\":\"analogValue\",\"object_id\":27,\"device_id\":12035},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":9},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":36},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":10},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":11},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":13},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":14},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":15},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":16},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":19},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":20},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":21},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":37},{\"index\":9,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":38},{\"index\":10,\"object_names\":\"ZN-SP\",\"object_type\":\"analogValue\",\"object_id\":1103,\"device_id\":39}]","payloadType":"json","x":270,"y":460,"wires":[["771a31ca4db80de2"]]},{"id":"771a31ca4db80de2","type":"ui_template","z":"4895ea10b4ee9ead","group":"f541ab73c138159c","name":"","order":0,"width":0,"height":0,"format":"<style>\n td, th {\n text-align: left;\n vertical-align: middle;\n }\n</style>\n\n<table style=\"width:100%\">\n <tr>\n <th>Index</th>\n <th>Object_Name</th>\n <th>Object_Type</th>\n <th>Object_ID</th>\n <th>Device_ID</th>\n </tr>\n <tr ng-repeat=\"x in msg.payload | limitTo:200\">\n <td>{{x.index}}</td>\n <td>{{x.object_names}}</td>\n <td>{{x.object_type}}</td>\n <td>{{x.object_id}}</td>\n <td>{{x.device_id}}</td>\n </tr>\n</table>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":470,"y":460,"wires":[[]]},{"id":"f541ab73c138159c","type":"ui_group","name":"Default","tab":"8f97582059cc55ea","order":1,"disp":true,"width":"16","collapse":false},{"id":"8f97582059cc55ea","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![bbartling](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bbartling](https://discourse.nodered.org/u/bbartling)\
**Post date:** [11 September 2021 19:23 UTC](https://discourse.nodered.org/t/display-table-data-from-sqlite/50896/6 "2021-09-11T19:23:07Z")

</div>

Thank you

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [11 September 2021 20:01 UTC](https://discourse.nodered.org/t/display-table-data-from-sqlite/50896/7 "2021-09-11T20:01:03Z")

</div>

I suggest you try this node **node-red-node-ui-table**. It makes a perfect table, with column sorting, resizing, shading.  
Simply plug your query output into this node.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/2/f25314b14748237f2bf2900f1fa67bf65c796781.png)

 ![screenshot](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/1/6182554f0c7ce3ee44b6e786f6bccf9d3c7806ce.png)

---

<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:** [25 September 2021 20:01 UTC](https://discourse.nodered.org/t/display-table-data-from-sqlite/50896/8 "2021-09-25T20:01:11Z")

</div>

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