# Basic function for sending an array to data table

**URL:** <https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689>\
**Category:** Dashboard\
**Tags:** dashboard-2\
**Created:** [26 October 2024 12:05 UTC](https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689 "2024-10-26T12:05:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![xlameee](https://avatars.discourse-cdn.com/v4/letter/x/4da419/32.png) [@xlameee](https://discourse.nodered.org/u/xlameee)\
**Post date:** [26 October 2024 12:05 UTC](https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689/1 "2024-10-26T12:05:31Z")

</div>

Can someone create me simple basic function node how to structure the array and send it to the data table

Thank you

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [26 October 2024 12:33 UTC](https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689/2 "2024-10-26T12:33:44Z")

</div>

Have you read the documentation, it gives example of data structure. [Data Table ui-table | Node-RED Dashboard 2.0](https://dashboard.flowfuse.com/nodes/widgets/ui-table.html)  
Any Database query result would be an acceptable data structure.

---

<div class="post-metadata">

**Author:** ![xlameee](https://avatars.discourse-cdn.com/v4/letter/x/4da419/32.png) [@xlameee](https://discourse.nodered.org/u/xlameee)\
**Post date:** [26 October 2024 13:31 UTC](https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689/3 "2024-10-26T13:31:46Z")

</div>

So this one is acceptable JSON array

```auto
[
    {
        "key1": "string1",
        "key2": "string2",
        "key3": "string3",
        "key4": "string4",
        "key5": "string5",
        "key6": "string6",
        "key7": 20,
        "key8": 10.14,
        "key9": 10.98,
        "key10": 10.63
    }
]

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [26 October 2024 13:44 UTC](https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689/5 "2024-10-26T13:44:04Z")

</div>

Yes, an array of objects is fine, and you can define which object property you wish to display in the table node.  
by adding properties at the bottom of the config.

 ![chrome_screenshot_26 Oct 2024 14_43_17 BST](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d0b2be97f1e5473d9747cd8465d1006db6868e7a.png)  
Or use Auto calculate columns.

---

<div class="post-metadata">

**Author:** ![xlameee](https://avatars.discourse-cdn.com/v4/letter/x/4da419/32.png) [@xlameee](https://discourse.nodered.org/u/xlameee)\
**Post date:** [26 October 2024 14:02 UTC](https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689/6 "2024-10-26T14:02:47Z")

</div>

Yes with table node all working fine but I use template node for more customization and I have an issue with it I told might be a array issue but seems is not.

in here if you can give me some help with it.

> [@Problem adding \<div\> custom-header class to v-slot:header.name](https://discourse.nodered.org/t/problem-adding-div-custom-header-class-to-v-slot-header-name/92673/4):
>
> Here is the template I don't understand why this is not working. I use the same template for other data and I do not have problem \<template\> \<div\> \<v-card flat\> \<v-card-title class="d-flex align-center pe-2"\> \<v-icon icon="mdi-check"\>\</v-icon\> &nbsp; Pending Trades ({{ msg?.payload[0]?.tradeCount || 0 }}) \<v-spacer\>\</v-spacer\> \<v-text-field v-model="search" density="compact" label="Search" prepend-inner-icon="mdi-magnify" variant="solo-filled"…

---

<div class="post-metadata">

**Author:** ![xlameee](https://avatars.discourse-cdn.com/v4/letter/x/4da419/32.png) [@xlameee](https://discourse.nodered.org/u/xlameee)\
**Post date:** [26 October 2024 18:13 UTC](https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689/7 "2024-10-26T18:13:32Z")

</div>

why is this chip not working? I do not get it on Trade#, Pair and Status is working the rest is not

```auto
<template>
  <div>
    <!-- Data Table -->
    <v-data-table 
      :items="trades" 
      :headers="headers">
      <template v-slot:item.liveProfit="{ item }">
        <v-chip color="green">
          {{ item.liveProfit }}
        </v-chip>
      </template>
    </v-data-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      trades: [
        {
            "trade": "#78",
            "pair": "BNBUSDT",
            "buyPrice": 985.24,
            "sellPrice": 988.22,
            "livePrice": 943.73,
            "status": "Closed",
            "liveProfit": -49.69
        },
        {
            "trade": "#35",
            "pair": "ETHUSDT",
            "buyPrice": 993.13,
            "sellPrice": 1034.14,
            "livePrice": 1036.59,
            "status": "Closed",
            "liveProfit": -42.83
        },
        {
            "trade": "#1",
            "pair": "XRPUSDT",
            "buyPrice": 1072.17,
            "sellPrice": 986.02,
            "livePrice": 902.83,
            "status": "Pending",
            "liveProfit": -27.26
        },
        {
            "trade": "#41",
            "pair": "BTCUSDT",
            "buyPrice": 1009.85,
            "sellPrice": 955.31,
            "livePrice": 1014.21,
            "status": "Open",
            "liveProfit": 18.67
        },
        {
            "trade": "#9",
            "pair": "XRPUSDT",
            "buyPrice": 1055.59,
            "sellPrice": 1028.86,
            "livePrice": 932.79,
            "status": "Open",
            "liveProfit": -29.59
        },
        {
            "trade": "#79",
            "pair": "XRPUSDT",
            "buyPrice": 976.28,
            "sellPrice": 917.95,
            "livePrice": 984.3,
            "status": "Open",
            "liveProfit": 31.48
        },
        {
            "trade": "#75",
            "pair": "XRPUSDT",
            "buyPrice": 958.66,
            "sellPrice": 957.73,
            "livePrice": 1070.52,
            "status": "Closed",
            "liveProfit": -38.13
        },
        {
            "trade": "#91",
            "pair": "XRPUSDT",
            "buyPrice": 920.06,
            "sellPrice": 923.24,
            "livePrice": 1082.75,
            "status": "Open",
            "liveProfit": -5.78
        },
        {
            "trade": "#88",
            "pair": "BNBUSDT",
            "buyPrice": 940.86,
            "sellPrice": 956.62,
            "livePrice": 990.71,
            "status": "Pending",
            "liveProfit": -36.24
        },
        {
            "trade": "#48",
            "pair": "BTCUSDT",
            "buyPrice": 919.83,
            "sellPrice": 966.62,
            "livePrice": 1031.91,
            "status": "Closed",
            "liveProfit": -16.79
        }
      ],
      headers: [
        { title: 'Trade#', key: 'trade' },
        { title: 'Pair', key: 'pair' },
        { title: 'Entry Price', key: 'buyPrice' },
        { title: 'Exit Price', key: 'sellPrice' },
        { title: 'Current Price', key: 'livePrice' },
        { title: 'Current Profit', key: 'liveProfit' },
        { title: 'Status', key: 'status' },
      ]
    };
  }
};
</script>

```

---

<div class="post-metadata">

**Author:** ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)\
**Post date:** [28 October 2024 09:39 UTC](https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689/8 "2024-10-28T09:39:19Z")

</div>

I think you're seeing [Small problem with v-table in template node - #2 by Steve-Mcl](https://discourse.nodered.org/t/small-problem-with-v-table-in-template-node/92324/2)

---

<div class="post-metadata">

**Author:** ![xlameee](https://avatars.discourse-cdn.com/v4/letter/x/4da419/32.png) [@xlameee](https://discourse.nodered.org/u/xlameee)\
**Post date:** [28 October 2024 15:39 UTC](https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689/9 "2024-10-28T15:39:11Z")

</div>

That's crazy it works. I was stack for like 5 days on that. Thank you

---

<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:** [11 November 2024 15:39 UTC](https://discourse.nodered.org/t/basic-function-for-sending-an-array-to-data-table/92689/10 "2024-11-11T15:39:48Z")

</div>

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