I have the following table:
$(document).ready(function() {
var table = $('#tblClientes').DataTable({
'select': true,
'paging': true,
'info': true,
'filter': true,
'stateSave': true,
'processing': false,
'serverSide': false,
.....
});
});
And the following code also:
var mult_select = function(tbody, table){
$('#tblClientes tbody').on( 'click', 'tr', function () {
table.on('select.dt', function() {
var array = [];
table.rows('.selected').every(function(rowIdx) {
array.push(table.row(rowIdx).data())
});
console.log(array);
});
});
}
The goal is that when selecting a set of rows you can send by ajax the id of each of them to make an SQL query.
The problem is that the console.log (array) every time I select or deselect shows me more and more, it is as if they were accumulating. I want that every time I select one or two (or more) I show everything in the same object in the array as the second display of the image.
Thanks in advance !!