I am using datatables 1.10.19 in vue js. Here i have dynamic table on clicking some button it filters and replace table by new data to tr tag of table.How can i refresh table with new content? i used clear, destroy but no thing works.Here is my entire code.
2 Answers
Update your code like this, it should work
$('.reportDataTableModelWise').DataTable().destroy();
before calling data from this.$store.commit('modelWiseTabularReport');
and update your updated code like this
this.$nextTick(function() {
$('.reportDataTableModelWise').DataTable({
'destroy' : true,
'paging' : true,
'lengthChange': true,
'searching' : true,
'ordering' : true,
'order' : [[ 5, 'desc' ]],
'info' : true,
'autoWidth' : false,
'dom' : 'Blfrtip',
'buttons' : [
{
'extend': 'csv',
'title': this.$route.meta.report_name + ' Report'
},
{
'extend': 'pdf',
'title': this.$route.meta.report_name + ' Report'
},
{
'extend': 'print',
'title': this.$route.meta.report_name + ' Report'
}
]
});
});
The $nextTick is necessary to ensure Vue has flushed the new data to the DOM, before re-initializing.
$('#datatable').DataTable().ajax.reload();