Reputation: 23
I use JQuery dataTable version 1.9. I need to reload a datatable after ajax success because I filter the elements after my query so the pagination shows all elements and not just the "real" ones filtered after the query. I know it is wrong to do this but I can only check after the query
Here it seems that there are no elements
But when scrolling through the pagination the elements are there
Upvotes: 0
Views: 374
Reputation: 1101
If you are going to reload datatable after ajax call, then, you should have the data as a list of object. Let's say it is stored in data
Then, reload table by
function reloadDataTable(tableObject, data) {
tableObject.clear().rows.add(data).draw();
};
Upvotes: 0
Reputation: 746
you can use setInterval for reloading the datatable after ajax reuqest
setInterval(function(){
$('#tableid').DataTable({
});
}, 300);
Upvotes: 1
Reputation:
Please test this solution
function refreshTable() {
$('.dataTable').each(function() {
dt = $(this).dataTable();
dt.fnDraw();
})
}
Upvotes: 0