Reputation: 752
I have two datatable the first datatable when checkbox is checked the rows are transferred to a new jquery datatable. I also I have a chk all checkbox when the checkbox is checked I want all the table rows to be transfered to the other datatable.
Here are the two tables
var primaryTable = $('#tblProveedorToTransfert').DataTable({
//code that generates datatable
});
var secondTable = $('#tblProveedorTransferd').DataTable({
//code that generates datatable
});
This is the code that should transfer all the rows to the other table. However only the rows that are visually visible are transferred and not all the rows on all the pages.
$('#chkAll').click(function (e) {
$(this).closest('table').find('td input:checkbox').prop('checked', this.checked);
$('#tblProveedorToTransfert tbody').find('input[type="checkbox"]').each(function () {
var alereadyAdded = false;
if ($(this).is(":checked")) {
for (var i = rowsIDs.length - 1; i >= 0; i--) {
if (rowsIDs[i] === $(this).attr("data-id"))
{
alereadyAdded = true;
}
}
if (alereadyAdded === false)
{
rowsIDs.push($(this).attr("data-id"));
}
}
else {
for (var i = rowsIDs.length - 1; i >= 0; i--) {
if (rowsIDs[i] === $(this).attr("data-id")) {
rowsIDs.splice(i, 1);
}
}
}
secondTable.ajax.reload();
});
});
What must I modify in my code to transfer all the rows and not just the visible ones. Thank you for your help.
Upvotes: 0
Views: 85
Reputation: 1101
Upvotes: 1