datatables auto pagination stopping after all rows have been displayed

datatables auto pagination stopping after all rows have been displayed

bytecbytec Posts: 26Questions: 6Answers: 0

Hi all,
The script below returns multiple rows of data from a Ajax call which are then displayed on screen using dataTables.
If the I set the script to display two (2) rows and then auto pagination to the next two rows works until the last
rows are displayed. It then returns to the first two rows and stops.

can anyone see where I have gone wrong.

$(document).ready( function () {
var imagepath = "../../../../../../";
var table = $('#glafids').DataTable( {   
        pageLength: 2, // SET NUMBER OD ROWS TO DISPLAY
        responsive: true,
        autoWidth: false,
        ordering: false,
        searching: false,
        scrollCollapse: true,
  ajax: {
      url: 'get_fids.php', 
      dataSrc: '',
   },
    language: {
      "emptyTable": "There are no more departures for <?php echo $date; ?>"
    },
    columns: [
      { data: "Image", width: '10%', render : function (data, type){
        if (data === "") {
        return '<img src="' + noimage + '"/>';
        } else {
        return '<img src="' + imagepath + '' +data+'" />';
        }
       }
      },
     { data: "ScheduleTime", width: '10%' },
     { data: "AirportName",  width: '38%'},
     { data: "Flight",  width: '12%'},
     { data: "Terminal",  width: '12%'},
     { data: "RemarksWithTime",  width: '12%'}
     ],
     /// rowCallback: function(row, data){ 

   //},
  });
  // Get the page info, so we know what the last is

  var pageInfo = table.page.info(),

      // Set the ending interval to the last page
      endInt = pageInfo.end,

      // Current page
      currentInt = 0,

      // Start an interval to go to the "next" page every 3 seconds
      interval = setInterval(function(){
      // "Next" ...
      table.page( currentInt ).draw( 'page' );

      // Increment the current page int
      currentInt++;

      // If were on the last page, reset the currentInt to the first page #
      if ( currentInt ===  endInt)
        currentInt = 0;

      }, 3000); // 3 seconds


//console.log("INFO",pageInfo );      
});

Answers

Sign In or Register to comment.