How to Select All Checkbox not Existing in current "DOM"
How to Select All Checkbox not Existing in current "DOM"
Sageis1
Posts: 53Questions: 9Answers: 0
Hello all,
The current solution contains a select all button that is suppose to "Check" all rows in the table, i noticed that the java-script below does select all rows, but not on the other "pages", only in the current page
$('#selectAll').click(function (e) {
var checkBoxes = document.getElementById('datatables').querySelectorAll('input[type=checkbox]');
if ($(this).hasClass('checkedAll')) {
$(checkBoxes).prop('checked', false);
$(this).removeClass('checkedAll');
} else {
$(checkBoxes).prop('checked', true);
$(this).addClass('checkedAll');
}
});
Then i can across an SO article on how non visible rows dont exist in the DOM.
So my Question is how to Select All rows both non visible and visible.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You can use
rowCallback
to update the state of the checkboxes for each table draw.Kevin
Hello @kthorngren, Im not particulary sure how i would use the rowCallback option to check all checkboxes, could you show me, im currently using this test case as a example: http://live.datatables.net/weluyanu/53/edit
I had this old example that works:
http://live.datatables.net/mutavegi/5/edit
It uses
cell().node()
to set the checkbox state instead of directly in the DOM.Kevin