I am trying to make an expandable v-data-table in vue3 and vuetify3. The normal data table worked fine. However when I am trying an expandable v-data-table. It does not display anything but loads data as appears from the pagination.
Updated code: All of the rows expand together now
<script setup>
import { ref } from 'vue'
import currencyHelpers from '../lib/currencyHelpers';
const info = ref([]);
const currencies = ref([]);
const headers = [
{ title: 'Name', value: 'currencydefinition.fullyqualifiedname' },
{ title: 'ID', value: 'currencydefinition.currencyid' },
{ title: 'ID rego fee', value: 'currencydefinition.idregistrationfees' },
{ title: 'ID import fee', value: 'currencydefinition.idimportfees' },
{ title: 'Converter Name', value: 'currencydefinition.gatewayconvertername' },
{ title: 'Proof Protocol', value: 'currencydefinition.proofprotocol' },
{ title: 'Options', value: 'currencydefinition.options' }
];
const expanded = ref(null);
(async () => {
info.value = await currencyHelpers.getInfo();
currencies.value = await currencyHelpers.listCurrencies();
})();
</script>
<template>
<v-layout>
<v-row>
<v-col>
<h1>Currencies</h1>
<v-container class="mx-auto pa-6">
<v-data-table
:items="currencies"
:headers="headers"
item-value="title"
v-model:expanded="expanded"
show-expand
>
<!-- expanded card content -->
<template v-slot:top>
<v-toolbar flat>
<v-toolbar-title>Version {{ info.VRSCversion }}</v-toolbar-title>
</v-toolbar>
</template>
<template v-slot:expanded-row="items">
<tr>
<td :colspan="headers.length">
More info about {{ headers }}
</td>
</tr>
</template>
</v-data-table>
</v-container>
</v-col>
</v-row>
</v-layout>
</template>
<style scoped>
</style>
This is the JSON response btw:
More info about [ { "title": "Name", "value": "currencydefinition.fullyqualifiedname" }, { "title": "ID", "value": "currencydefinition.currencyid" }, { "title": "ID rego fee", "value": "currencydefinition.idregistrationfees" }, { "title": "ID import fee", "value": "currencydefinition.idimportfees" }, { "title": "Converter Name", "value": "currencydefinition.gatewayconvertername" }, { "title": "Proof Protocol", "value": "currencydefinition.proofprotocol" }, { "title": "Options", "value": "currencydefinition.options" } ]
Something like this happens as in the screenshot below:

There are a few issues I notice in your code:
You're using
expandedRow.valueinside thetoggleExpansionmethod, butexpandedRowis not defined. Instead, you should useexpanded.In the expanded row template, you're trying to access
headers.title, which is incorrect. You should iterate over theheadersarray to display the titles.