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.
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...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.