jQuery DataTables Checkboxes: State saving
Example for https://www.gyrocode.com/projects/jquery-datatables-checkboxes/
HTML
<link rel="stylesheet" href="https://cdn.datatables.net/v/dt/dt-1.10.15/se-1.2.2/datatables.min.css">
<script src="https://cdn.datatables.net/v/dt/dt-1.10.15/se-1.2.2/datatables.min.js"></script>
<link rel="stylesheet" href="https://gyrocode.github.io/jquery-datatables-checkboxes/1.2.11/css/dataTables.checkboxes.css">
<script src="https://gyrocode.github.io/jquery-datatables-checkboxes/1.2.11/js/dataTables.checkboxes.min.js"></script>
<button type="button" onclick="window.location.reload()">Reload page</button>
<hr>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
</table>
JavaScript
$(document).ready(function (){
var table = $('#example').DataTable({
'ajax': 'https://api.myjson.com/bins/1us28',
'columnDefs': [
{
'targets': 0,
'checkboxes': {
'selectRow': true
}
}
],
'stateSave': true,
'select': 'multi',
'order': [[1, 'asc']],
rowId: 0
});
setInterval(function () {
table.ajax.reload(null, false);
}, 10000);
});