how create pagination automatic with animation fadeindows

how create pagination automatic with animation fadeindows

AntonioMote96AntonioMote96 Posts: 1Questions: 1Answers: 0

Hello, I have a problem with my table, I wanted to do automatic auto-pagination with an effect, but I have not succeeded, my data is already displayed well, but I have not achieved automatic pagination or animation.

My code

<?php include_once "conexionsql.php"; $con=conectarse(); ?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css">

<title>Hello, world!</title>

</head>
<body>
<h1>Hello, world!</h1>
<div class="col col-md-9 col-sm-6">
<section>
<table id="example"class="table nowrap" width="50%" >
<thead>
<tr>

  <th >Tracto</th>
  <th >Cliente</th>
  <th >BITACORA</th>
  <th >Orden</th>
  <th >Carga</th>
  <th >Dias</th>
  <th >Horas</th>
  <th >Destino</th>
  <th >Status</th>

</tr>

</thead>
<tfoot>
<tr>

  <th >TRACTO</th>
  <th >Cliente</th>
  <th >BITACORA</th>
  <th >Orden</th>
  <th >Carga</th>
  <th >Dias</th>
  <th >Horas</th>
  <th >Destino</th>
  <th >Status</th>

</tr>

</tfoot>

<tbody>
<?php
$sql = "EXEC rutas";
$stmt = sqlsrv_query( $con, $sql );
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}
//$i=0;
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {

    ?>      
<tr align="center">
  <td><?php echo $row['TRACTO']?></td>
  <td><?php echo $row['CLIENTE']?></td>
  <td><?php echo $row['BITACORA']?></td>
  <td><?php echo $row['ORDENSERVICIO']?></td>
  <td><?php echo $row['CARGA']->format('Y-m-d H:i:s');?></td>
  <td><?php echo $row['DIAS']?></td>
  <td><?php echo $row['HORAS']?></td>
  <td><?php echo $row['DESTINO']?></td>
  <td><?php echo $row['ESTATUS']?></td>

</tr>
<?php
 }
  ?>

</tbody>

</table>
</section>
</div>

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script>
<script >
    $(document).ready(function() {

function initTable(start) {
table = $('#example').DataTable({
"searching": false,
"destroy": true,
"displayStart": 4,
"pageLength": 12,

  initComplete: function() {
    var api = this.api();
    var rowCount = api.rows({
      page: 'current'
    }).count();


    for (var i = 0; i < api.page.len() - (rowCount === 0 ? 1 : rowCount); i++) {
      $('#example tbody').append($("<tr ><td>&nbsp;</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>"));
    }
  }
});

}

var pageLen = Math.round(($(window).height() - 500) / 40);
var table;

$('#example').addClass('animated fadeInDown');

initTable(0);

setInterval(function() {

var info = table.page.info();
var pageNum = (info.page < info.pages) ? info.page + 1 : 1;

initTable(pageNum * pageLen);

}, 3000);

});
</script>

</body>
</html>

Answers

  • allanallan Posts: 61,663Questions: 1Answers: 10,095 Site admin

    There is no option to do an fade / animation page change in DataTables I’m afraid.

    Allan

Sign In or Register to comment.