<!DOCTYPE html>
<html>
  <head>
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
    <script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
<link href="https://cdn.datatables.net/scroller/1.3.0/css/scroller.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.datatables.net/scroller/1.3.0/js/dataTables.scroller.js"></script>
    <meta charset=utf-8 />
    <title>DataTables - JS Bin</title>
  </head>
  <body>
    <div class="container">
      <input id="indx"> <button id="goto">GoTo</button>
      <hr/>
      Last Row Created: <span id="lastRow">??</span>
      <hr/>
<table id="example" class="display nowrap" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>ID</th>
                <th>First name</th>
                <th>Last name</th>
                <th>ZIP / Post code</th>
                <th>Country</th>
            </tr>
        </thead>
    </table>
    </div>
  </body>
</html>
 
body {
  font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 0;
  color: #333;
  background-color: #fff;
}
 
$(document).ready( function () {
  var table = $('#example').DataTable({
        ajax:           "http://linuxdigest.org/misc/dt_ajax_srcs/src1.php",
        deferRender:    true,
        scrollY:        200,
        scrollCollapse: true,
        scroller:       true,
    createdRow: function( row, data, dataIndex ) {
      console.log('Row indx is', dataIndex);
      $('#lastRow').text(dataIndex);
    }
    } );
  
  $('#goto').click(function(){
    table.row( parseInt($('#indx').val()) ).scrollTo();
  });
} );
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers