datatables自动分页未显示正确的行数且未重置行计数器

dohp0rv5  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(243)

下面的脚本返回多行数据,然后使用datatables在屏幕上显示这些数据。我的问题有两个方面,首先要显示的行数设置为两(2),但当脚本运行时,它会显示所有行。其次,脚本没有将“currentint”重置为第一页。
谁能看出我哪里出了错。

$(document).ready( function () {
var imagepath = "../../../../../../";
var table = $('#glafids').DataTable( {   
        pageLength: 2, // SET NUMBER OD ROWS TO DISPLAY
        responsive: true,
        autoWidth: false,
        ordering: false,
        paging: 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 );      
});

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题