Reputation: 141
I am using Datatables with selected extension with checkboxes and I am trying to get the number of the selected rows after I deselect one or all.
This code works perfectly with all deselection (I got always zero) but If I deselect only one row I get the number of selected rows plus one. It seems the event fire earlier somehow.
table.on('deselect', function(e, dt, type, indexes) {
var numberOfSelectedRows = table.column(0).checkboxes.selected().length;
// ...
});
If I wrap the code with a setTimeout It works perfectly, but it's messy.
Upvotes: 1
Views: 367
Reputation: 2832
Can't you just use rows_selected.length if you're following the jsfiddle provided by the checkboxes lab? So on click of the row/checkbox, just check the array length to see what the count is for what is still checked...
Upvotes: 0