automatic switching between pages

automatic switching between pages

2Sleepy2Sleepy Posts: 4Questions: 0Answers: 0
edited November 2012 in General
Hello, please tell me how to implement this: we need to make the transition between pages to start automatically at a specific interval of time and reaching the last page back to the first.

it will be something like the flight schedules

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Use the fnPageChange method: http://datatables.net/api#fnPageChange :-)

    Allan
  • 2Sleepy2Sleepy Posts: 4Questions: 0Answers: 0
    edited November 2012
    Thank you very much,
    I still need something like this ...
    http://live.datatables.net/#source

    and after the last page back to the first
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Okay - you can use the fnPagingInfo plug-in ( http://datatables.net/plug-ins/api#fnPagingInfo ) to find out if you are on the last page or not and alter the parameters given to fnPageChange as needed.

    Allan
  • 2Sleepy2Sleepy Posts: 4Questions: 0Answers: 0
    Thanks, I will try ...
  • 2Sleepy2Sleepy Posts: 4Questions: 0Answers: 0
    edited November 2012
    To automatically switch between the pages

    [code]
    var oTable = $('#example').dataTable();
    max = oTable.fnPagingInfo().iTotalPages;
    ctr=0;
    setInterval(function(){
    if (ctr <= max){
    oTable.fnPageChange( 'next' );
    ctr=ctr+1;
    }
    else{
    oTable.fnPageChange( 'first' );
    ctr=0;
    }
    },10000);//time interval, seconds
    });
    [/code]
This discussion has been closed.