Несмотря на то, что вопрос помечен как «отвеченный» для тех, кто может столкнуться с той же проблемой, решение, для которого OP запросил, в основном, сводится к одной приятной и аккуратной строчке:
const ifAllChecked = col => dataTable.rows().nodes().toArray().every(row => $(row).find(`td:eq(${col}) [type="checkbox"]`).is(':checked'));
Ниже приводится краткое описание ДЕМО того, как это можно сделать:
//define source data
const srcData = [
{city: 'Kyiv', visited: true, enjoyed: true},
{city: 'Istanbul', visited: true, enjoyed: true},
{city: 'Moscow', visited: true, enjoyed: false},
{city: 'Nicosia', visited: true, enjoyed: true},
{city: 'New York', visited: false, enjoyed: false},
{city: 'Cairo', visited: true, enjoyed: true}
];
//define datatables object
const dataTable = $('#mytable').DataTable({
sDom: 'tp',
pageLength: 3,
data: srcData,
columns: [
{title: 'city', data: 'city'},
{
title: 'visited',
data: 'visited',
render: (data, type, row, meta) => `<input type="checkbox" colindex="${meta.col}" ${data ? 'checked' : ''} style="float:right;margin-right:28px" class="regularchckbx"></input>`
},
{
title: 'enjoyed',
data: 'enjoyed',
render: (data, type, row, meta) => `<input type="checkbox" colindex="${meta.col}" ${data ? 'checked' : ''} style="float:right;margin-right:28px" class="regularchckbx"></input>`
},
]
});
//essential part of the solution OP was looking for
const ifAllChecked = col => dataTable.rows().nodes().toArray().every(row => $(row).find(`td:eq(${col}) [type="checkbox"]`).is(':checked'));
//put 'check all' checkboxes into header
$(dataTable.columns([1,2]).header()).append(`<input type="checkbox" class="allchecked" style="float:right;margin-right:20px"></input>`);
//set initial header checkboxes state
[1, 2].forEach( col => dataTable.column(col).header().querySelector('[type="checkbox"]').checked = ifAllChecked(col));
//listen for changes and adjust 'check-alls'
$('#mytable').on('click', '.regularchckbx', function(){
dataTable.column($(this).attr('colindex')).header().querySelector('[type="checkbox"]').checked = ifAllChecked($(this).attr('colindex'));
});
//check/uncheck all
$('.allchecked').on('click', function(){
let col = dataTable.column($(this).closest('th')).index();
let state = this.checked;
dataTable.rows().every(function(){
this.node().querySelector(`[colindex="${col}"]`).checked = state;
});
});
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<script type="application/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="application/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
</head>
<body>
<table id="mytable"></table>
</body>
</html>