JSFiddle - React, Tailwind, and code Playground
by Preservin
HTML
<link rel="stylesheet" href="https://cdn.datatables.net/v/dt/jq-2.2.4/pdfmake-0.1.18/dt-1.10.13/b-1.2.4/b-colvis-1.2.4/b-html5-1.2.4/b-print-1.2.4/cr-1.3.2/fc-3.2.2/fh-3.1.2/r-2.1.0/sc-1.4.2/datatables.min.css">
<script src="https://cdn.datatables.net/v/dt/jq-2.2.4/pdfmake-0.1.18/dt-1.10.13/b-1.2.4/b-colvis-1.2.4/b-html5-1.2.4/b-print-1.2.4/cr-1.3.2/fc-3.2.2/fh-3.1.2/r-2.1.0/sc-1.4.2/datatables.min.js"></script>
<body>
<div class="container">
<button id="scrollto_Bruno">scrollto Bruno Nash</button>
<button id="scrollto_Jenette">scrollto Jenette Caldwell</button>
<table id="example" class="display nowrap" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr id="1">
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$3,120</td>
</tr>
<tr id="2">
<td>Garrett Winters</td>
<td>Director</td>
<td>Edinburgh</td>
<td>63</td>
<td>2011/07/25</td>
<td>$5,300</td>
</tr>
<tr id="3">
<td>Ashton Cox</td>
<td>Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$4,800</td>
</tr>
<tr id="4">
<td>Cedric Kelly</td>
<td>Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
...
CSS
body {
font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
color: #333;
background-color: #fff;
}
#example tbody td {
white-space: normal !important;
}
JavaScript
$(document).ready( function () {
var the_table = $('#example').DataTable({
dom: 'frtip',
scrollY: "200px",
scroller: true,
"sScrollX": false,
"bAutoWidth": false,
aaSorting : [[0, "asc"]],
/*buttons: [
'colvis'
],*/
});
$('#scrollto_Bruno').click(function(){
console.log('asd');
the_table.row($('#example').find('#43')).scrollTo();
});
$('#scrollto_Jenette').click(function(){
console.log('asd');
the_table.row($('#example').find('#21')).scrollTo();
});
the_table.draw();
the_table.on( 'order', function () {
console.log( 'Table redrawn' );
} );
} );