I already installed dataTables using npm i dataTables --save
, and now I can see the dataTable format in my vue component, the problem is the searchbar,paginations are not working well. See my screenshot
code in my component
<table class="table table-hover" id="myTable">
<thead>
<tr>
<th>Room Name</th>
<th>Building</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr v-for="room in roomsData" :key="room.id">
<td>{{room.room_desc}}</td>
<td>{{room.bldg}}</td>
<td>
<a href="#" data-toggle="modal" data-target="#exampleModal" @click="editModal(room)">
<i class="fa fa-edit"></i>
</a>
<a href="#" @click="deleteRoom(room.id)">
<i class="fa fa-trash text-red"></i>
</a>
</td>
</tr>
</tbody>
</table>
Methods
myTable(){
$(document).ready( function () {
$('#myTable').DataTable();
});
}
getRoomsDataTable(){
axios.get('/getRoomsDatatable')
.then((res) => {
this.roomsData = res.data
}) .catch((e) => {
console.log(e)
})
},