Can't select after reload
Can't select after reload
I am using the code, below, but selections are always cancelled after reload:
<script>
$(document).ready(function() {
var table = $('#example').DataTable( {
select: true,
stateSave: true,
ajax: '/api/staff',
rowId: 'staffId',
columnDefs: [ {
orderable: false,
className: 'select-checkbox',
targets: 0
} ],
select: {
style: 'os',
selector: 'td:first-child'
},
order: [[ 1, 'asc' ]],
"ajax": "data.txt"
} );
setInterval( function () {
table.ajax.reload( null, false );
}, 10000 );
} );
</script>
This discussion has been closed.
Answers
Do you have a column with a unique ID? If so use
rowIdto set that as the row ID and the rows will be reselected after theajax.reload(). Otherwise you will need to reselect the rows yourself. Try this:http://live.datatables.net/badawika/1/edit
It gets the selected rows then uses a callback function for the
ajax.reload()API to reselect the rows.Kevin