i've tried to create a v-data-table including so i can add another field with a button, but it seems that is not working.
Here is the code:
The thing is when i change the package .5.14/vuetify.min.js with to a newest version like this one: .0.15/vuetify.min.js the table ignore the tag.
HTML
<v-app id="inspire">
<v-data-table
:headers="headers"
:items="desserts"
class="elevation-1"
>
<template v-slot:items="props">
<td>{{ props.item.name }}</td>
<td >{{ props.item.calories }}</td>
<td>{{ props.item.fat }}</td>
<td><v-btn>Created Button</v-btn></td>
</template>
</v-data-table>
</v-app>
</div>
JS
new Vue({
el: '#app',
data () {
return {
headers: [
{
text: 'Dessert (100g serving)',
align: 'left',
sortable: false,
value: 'name'
},
{ text: 'Calories', value: 'calories' },
{ text: 'Fat (g)', value: 'fat' },
{ text: 'Button field', value: 'buttonField' },
],
desserts: [
{
name: 'Frozen Yogurt',
calories: 159,
fat: 6.0,
},
{
name: 'Ice cream sandwich',
calories: 237,
fat: 9.0,
},
{
name: 'Eclair',
calories: 262,
fat: 16.0,
}
]
}
}
})
I don't get any error, only the table stops appearing. Could it be a version problem?
i've tried to create a v-data-table including so i can add another field with a button, but it seems that is not working.
Here is the code: https://codepen.io/gerak/pen/yLBpqqG
The thing is when i change the package https://cdnjs.cloudflare./ajax/libs/vuetify/1.5.14/vuetify.min.js with to a newest version like this one: https://cdnjs.cloudflare./ajax/libs/vuetify/2.0.15/vuetify.min.js the table ignore the tag.
HTML
<v-app id="inspire">
<v-data-table
:headers="headers"
:items="desserts"
class="elevation-1"
>
<template v-slot:items="props">
<td>{{ props.item.name }}</td>
<td >{{ props.item.calories }}</td>
<td>{{ props.item.fat }}</td>
<td><v-btn>Created Button</v-btn></td>
</template>
</v-data-table>
</v-app>
</div>
JS
new Vue({
el: '#app',
data () {
return {
headers: [
{
text: 'Dessert (100g serving)',
align: 'left',
sortable: false,
value: 'name'
},
{ text: 'Calories', value: 'calories' },
{ text: 'Fat (g)', value: 'fat' },
{ text: 'Button field', value: 'buttonField' },
],
desserts: [
{
name: 'Frozen Yogurt',
calories: 159,
fat: 6.0,
},
{
name: 'Ice cream sandwich',
calories: 237,
fat: 9.0,
},
{
name: 'Eclair',
calories: 262,
fat: 16.0,
}
]
}
}
})
I don't get any error, only the table stops appearing. Could it be a version problem?
Share Improve this question asked Sep 6, 2019 at 13:51 Gerardo QuirosGerardo Quiros 532 silver badges6 bronze badges 1- I see errors in the console if I change your codepen to use 2.0.15 Did you change the css too? Not that it seems to matter. – Xotic750 Commented Sep 6, 2019 at 14:02
1 Answer
Reset to default 4The slots are working differently, you've template per field, to add buttons in a table you can do it like this (https://codepen.io/reijnemans/pen/dybJgjL?editors=1010) :
<div id="app">
<v-app id="inspire">
<v-data-table
:headers="headers"
:items="desserts"
class="elevation-1"
>
<template v-slot:item.action="{ item }">
<v-btn>Created Button</v-btn>
</template>
</v-data-table>
</v-app>
</div>
JS:
new Vue({
el: '#app',
vuetify: new Vuetify(),
data () {
return {
headers: [
{
text: 'Dessert (100g serving)',
align: 'left',
sortable: false,
value: 'name'
},
{ text: 'Calories', value: 'calories' },
{ text: 'Fat (g)', value: 'fat' },
{ text: 'Actions', value: 'action', sortable: false }
],
desserts: [
{
name: 'Frozen Yogurt',
calories: 159,
fat: 6.0,
},
{
name: 'Ice cream sandwich',
calories: 237,
fat: 9.0,
},
{
name: 'Eclair',
calories: 262,
fat: 16.0,
}
]
}
}
})