Basic function for sending an array to data table

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

Thank you

Have you read the documentation, it gives example of data structure. Data Table ui-table | Node-RED Dashboard 2.0
Any Database query result would be an acceptable data structure.

So this one is acceptable JSON array

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

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.


Or use Auto calculate columns.

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.

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

<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>

I think you're seeing Small problem with v-table in template node - #2 by Steve-Mcl

1 Like

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

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