I originally used the following code to select all my rows in the datatable:
$('#grid').DataTable().rows({ search: 'applied' }).select();
When using this, I immediately used the following to check if the count selected > 0. The count returned is correct.
$('#grid').DataTable().rows({ selected: true }).count()
I then wanted to use the iterator for all of the rows to be able to individually select or not select the row using the following code:
$('#grid').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
$(this.node()).addClass('selected')
});
After selecting rows using the iterator, I check if the count selected > 0 by using the same call used above. The count returned is 0.
$('#grid').DataTable().rows({ selected: true }).count()
I checked the source for the table rows and the 'selected' class is properly assigned to each of the table rows (tr). I compared the source from both approaches and the resulting HTML is the same.
Any thoughts as to why the behavior would be different?
Thanks.
Tom