I want to break DataTable() interations. Here is my code
let allCheckboxChecked=true; let table = $('#myTable').DataTable(); table.rows().iterator( 'row', function ( context, index ) { if($(this.row(index).node()).find("input").is(":Checked")){ allCheckboxChecked=true; } else{ allCheckboxChecked=false; **return true;** // This is not working...I want your help here } } );
Advertisement
Answer
Using nodes()
instead of iterator()
table.rows().nodes().to$().find('input:not(:checked):first').length // 0 - all checked
or with each()
let allCheckboxChecked = true; table.rows().nodes().to$().each(function () { if (!$(this).find('input').is(':checked')) { allCheckboxChecked = false; return false; } })