Update language.info after redrawing table
Update language.info after redrawing table
hafizctn
Posts: 5Questions: 3Answers: 0
I am updating data in an already drawn datatable. I want to show only the first 10 records to my users. But at the same time I also want to show the total number of records in my database. Following is my code:
function loadBooks (url){
$.ajax({
url: url,
type: "GET"
}).done(function (result) {
table2 .clear().draw();
table2 .rows.add(result.data).draw();
table2 .columns.adjust();
table2 .language.info = "Showing first 10 records of " + result.records;// unable to update the info.
table2 .responsive.recalc();
});
}
table2 = $("#table2").DataTable({
"language": {
"info": "Showing page _PAGE_ of _PAGES_ Records: _TOTAL_"
}
});
Any help please.
This question has an accepted answers - jump to answer
Answers
Maybe using
infoCallback
is more appropriate for you requirements. Assignresult.records
to a global variable that you can access from within theinfoCallback
function.Kevin
Thank you. It did the trick.
Here is the complete solution for the benefit of the others: