Update language.info after redrawing table
Update language.info after redrawing table
 hafizctn            
            
                Posts: 5Questions: 3Answers: 0
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
This discussion has been closed.
            
Answers
Maybe using
infoCallbackis more appropriate for you requirements. Assignresult.recordsto a global variable that you can access from within theinfoCallbackfunction.Kevin
Thank you. It did the trick.
Here is the complete solution for the benefit of the others: