I have the following JSON data:
[
{
"amount": 75,
"date": "2020-04-22",
"entradas": [
{
"date": "2020-04-22",
"amount": "100.00",
"title": "test 1"
},
{
"date": "2020-04-22",
"amount": "-25.00",
"title": "test 2"
}
]
},
{
"amount": 10,
"date": "2020-04-30",
"entradas": [
{
"date": "2020-04-30",
"amount": "10.00",
"title": "test 3"
}
]
}
]
What I would like to achieve is render all these "entradas" records together, so in this case it should render 3 rows at the Data Table, one for each "entradas".
I have the following basic method to load the json by axios:
methods: {
loadData () {
axios.get('dataapi')
.then(response => this.dataItems = response.data)
},
}
and
data () {
return {
headers: [
{
text: 'Data',
align: 'start',
sortable: false,
value: 'date',
},
{ text: 'Title', value: 'title', sortable: false },
{ text: 'Amount', value: 'amount', sortable: false },
],
dataItems: []
}
},
<template>
<v-app id="testdatatable">
<v-data-table
:headers="headers"
:items="dataItems.entradas"
class="elevation-1"
></v-data-table>
</v-app>
</template>
The problem is that when I use :items="dataItems.entradas"
it just doesn't render anything. The same problems happens if I use just :items="dataItems"
and at the headers use something like value: 'entradas.title'
I've tried some workaround with .map function, as I've seem some similar examples, but I didn't figured out how could that help in this situation...