I am working on an expandable Vuetify v-data-table, and by default, the expand arrow appears on the right when using show-expand. However, I would like to move it to the leftmost column so that it appears as the first item in the row.
Here is my current Vuetify setup:
<v-data-table
v-model:expanded="expanded"
:headers="dessertHeaders"
:items="desserts"
item-value="name"
show-expand
>
<template v-slot:top>
<v-toolbar flat>
<v-toolbar-title>Expandable Table</v-toolbar-title>
</v-toolbar>
</template>
<template v-slot:expanded-row="{ columns, item }">
<tr>
<td :colspan="columns.length">
More info about {{ item.name }}
</td>
</tr>
</template>
</v-data-table>
</template>
<script>
export default {
data () {
return {
expanded: [],
dessertHeaders: [
{
title: 'Dessert (100g serving)',
align: 'start',
sortable: false,
key: 'name',
},
{ title: 'Calories', key: 'calories' },
{ title: 'Fat (g)', key: 'fat' },
{ title: 'Carbs (g)', key: 'carbs' },
{ title: 'Protein (g)', key: 'protein' },
{ title: 'Iron (%)', key: 'iron' },
{ title: '', key: 'data-table-expand' },
],
desserts: [
{
name: 'Frozen Yogurt',
calories: 159,
fat: 6.0,
carbs: 24,
protein: 4.0,
iron: 1,
},
{
name: 'Ice cream sandwich',
calories: 237,
fat: 9.0,
carbs: 37,
protein: 4.3,
iron: 1,
},
{
name: 'Eclair',
calories: 262,
fat: 16.0,
carbs: 23,
protein: 6.0,
iron: 7,
},
{
name: 'Gingerbread',
calories: 356,
fat: 16.0,
carbs: 49,
protein: 3.9,
iron: 16,
},
{
name: 'KitKat',
calories: 518,
fat: 26.0,
carbs: 65,
protein: 7,
iron: 6,
},
],
}
},
}
</script>
here is a desired layout Issues: The expand arrow is positioned on the right of the table by default. I want it to be on the leftmost column, as shown in the desired layout. When I remove show-expand and try to place it manually, it doesn't toggle correctly.
I am working on an expandable Vuetify v-data-table, and by default, the expand arrow appears on the right when using show-expand. However, I would like to move it to the leftmost column so that it appears as the first item in the row.
Here is my current Vuetify setup:
<v-data-table
v-model:expanded="expanded"
:headers="dessertHeaders"
:items="desserts"
item-value="name"
show-expand
>
<template v-slot:top>
<v-toolbar flat>
<v-toolbar-title>Expandable Table</v-toolbar-title>
</v-toolbar>
</template>
<template v-slot:expanded-row="{ columns, item }">
<tr>
<td :colspan="columns.length">
More info about {{ item.name }}
</td>
</tr>
</template>
</v-data-table>
</template>
<script>
export default {
data () {
return {
expanded: [],
dessertHeaders: [
{
title: 'Dessert (100g serving)',
align: 'start',
sortable: false,
key: 'name',
},
{ title: 'Calories', key: 'calories' },
{ title: 'Fat (g)', key: 'fat' },
{ title: 'Carbs (g)', key: 'carbs' },
{ title: 'Protein (g)', key: 'protein' },
{ title: 'Iron (%)', key: 'iron' },
{ title: '', key: 'data-table-expand' },
],
desserts: [
{
name: 'Frozen Yogurt',
calories: 159,
fat: 6.0,
carbs: 24,
protein: 4.0,
iron: 1,
},
{
name: 'Ice cream sandwich',
calories: 237,
fat: 9.0,
carbs: 37,
protein: 4.3,
iron: 1,
},
{
name: 'Eclair',
calories: 262,
fat: 16.0,
carbs: 23,
protein: 6.0,
iron: 7,
},
{
name: 'Gingerbread',
calories: 356,
fat: 16.0,
carbs: 49,
protein: 3.9,
iron: 16,
},
{
name: 'KitKat',
calories: 518,
fat: 26.0,
carbs: 65,
protein: 7,
iron: 6,
},
],
}
},
}
</script>
here is a desired layout Issues: The expand arrow is positioned on the right of the table by default. I want it to be on the leftmost column, as shown in the desired layout. When I remove show-expand and try to place it manually, it doesn't toggle correctly.
dessertHeaders: [
{ title: '', key: 'data-table-expand' },
{
title: 'Dessert (100g serving)',
align: 'start',
sortable: false,
key: 'name',
},
{ title: 'Calories', key: 'calories' },
{ title: 'Fat (g)', key: 'fat' },
{ title: 'Carbs (g)', key: 'carbs' },
{ title: 'Protein (g)', key: 'protein' },
{ title: 'Iron (%)', key: 'iron' },
],
See Demo