I am trying to construct a data table with expanded rows, where I want the expanded part to take up the full width of the parent row. Unfortunatley the expanded row is automatically divided into columns, so if I add only one <div>
in the <template>
, that will be displayed under the first item of the parent row. How do I make the expanded-item take up the full width of the table?
I found a source achieving this, but the syntax is from what I understand not compatible with the version of Vuetify I am using: https://codepen.io/francobao/pen/mqxMKP
This is my component that contains the <v-data-table>
:
<template>
<div class="row">
<div class="col-12">
<v-data-table
:headers="headers"
hide-default-footer
item-key="name"
:items="getServiceProviders"
show-expand >
<template v-slot:expanded-item="{ headers, item }" >
<ServiceProviderDetails :isEditMode="true" :serviceProvider="item" />
</template>
</v-data-table>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
import ServiceProviderDetails from './ServiceProviderDetails';
export default {
name: 'ServiceProviderTable',
components: {
ServiceProviderDetails
},
computed: {
...mapGetters(['getServiceProviders'])
},
data () {
return {
headers: [
{
text: 'Name',
value: 'name'
},
{
text: 'Service Provider ID',
value: 'serviceProviderId'
}
]
}
}
}
</script>
This is the component to show in the expanded-row:
<template>
<div class="row sp-details">
<div class="col-4 text-right"><span>Name:</span></div>
<div class="col-4"><input class="details-input" type="text" v-model="details.name" /></div>
<div class="col-4"></div>
<div class="col-4 text-right"><span>PortalUrl:</span></div>
<div class="col-4"><input class="details-input" type="text" v-model="details.portalUrl" /></div>
<div class="col-4"></div>
<div class="col-4 text-right"><span>SupplierId:</span></div>
<div class="col-4"><input class="details-input" type="text" v-model="details.supplierId" /></div>
<div class="col-4"></div>
<div class="col-4 text-right"><p>Integration Enabled:</p></div>
<div class="col-4 text-left">
<span class="integration-switch" v-on:click="toggleIntegration(true)" ><input :checked="details.integrationEnabled" type="radio" />Yes</span>
<span class="integration-switch" v-on:click="toggleIntegration(false)" ><input :checked="!details.integrationEnabled" type="radio" />No</span>
</div>
<div class="col-4"></div>
<div class="col-8 offset-4 text-left">
<v-btn class="mr-2" color="secondary" :checked="details.integrationEnabled" v-on:click="$emit('cancel')">Cancel</v-btn>
<v-btn color="primary" v-on:click="$emit('save', details)">Save</v-btn>
</div>
</div>
</template>
<script>
export default {
name: 'ServiceProviderDetails',
props: \[ 'isEditMode', 'serviceProvider' \],
data () {
return {
details: {
name: '',
portalUrl: '',
supplierId: '',
integrationEnabled: false
}
}
},
mounted() {
if(this.isEditMode){
this.details = this.serviceProvider;
}
},
methods: {
toggleIntegration(isEnabled) {
this.details.integrationEnabled = isEnabled;
}
},
watch: {
serviceProvider: function() {
console.log('in serviceprovider')
if(this.isEditMode){
console.log(this.serviceProvider)
this.details = this.serviceProvider;
}
}
}
}
</script>
This is what the table header, first row and expanded row looks like: