hi i have problem im using datatable.net-vue3 and inertia so i have component reusable
hi i have problem im using datatable.net-vue3 and inertia so i have component reusable
"datatables.net-dt": "^2.1.7",
"datatables.net-vue3": "^3.0.2",
///
<template>
<Division class="table-responsive">
<DataTable :options="dataTableOptions" class="display table">
<thead>
<tr>
<th v-for="header in headers" :key="header">{{ header }}</th>
</tr>
<tr data-dt-order="disable">
<th v-for="header in headers" :key="header">{{ header }}</th>
</tr>
</thead>
<tbody>
<slot name="tbody" />
</tbody>
</DataTable>
</Division>
</template>
<style scoped>
.table-responsive {
min-height: 500px;
}
</style>
i have this components so in index i have used like this
<DataTable :items="subRentals" :headers="['Réf', 'Sous-traitant', 'Actions']">
<template #tbody>
<tr v-for="subRental in subRentals" :key="subRental.id" class="text-sm">
<td>
<SimpleLink v-tooltip="Voir le contrat en PDF
" :href="/p/sub-rental/${subRental.id}
">{{ subRental.ref }}</SimpleLink>
</td>
<td>{{ subRental.company.name }}</td>
<td>
<Division class="dropdown position-relative">
<Button class="btn btn-sm btn-outline-primary rounded dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
Actions
</Button>
<ul class="dropdown-menu dropdown-menu-end text-sm" aria-labelledby="dropdownMenuButton">
<li><Button class="dropdown-item text-success" @click="closeSubRentalFunc(subRental)">Fermer sous-location</Button></li>
</ul>
</Division>
</td>
</tr>
</template>
</DataTable>
when i close an subRental i lclosed with form PUT on modal make it closed so it should removed from datatable but it stack like datatable preserve old state this the problem
and i juust change the databale.net i was used but when i have one record on datatable it stack and show error of nextSubling on null
Replies
You can't use
v-for
to create the DataTable. You have to use the techniques shown in the documentation, otherwise you end up with both Vue and DataTables trying to control the same DOM elements, and that obviously won't work.Allan
so how about if i have complex data like this as columns
and i have used Datatable simpler withou library of datatable-net-vue3 it work good just one problem when i have the just one record in datatable and i closed it show me this
nextSubling on null
For syntax highlighting see this guide.
To use Vue components inside a DataTables column, please see the documentation here.
If you are getting an error, please create a test case using StackBltiz or a minimal git repo showing the issue.
Allan