I just upgraded from dt 1.13 -> 2.1 and found that the colVis buttons crashes when changing the column headers.
My use-case is that I want to include the sum total in the col header and also use the colVis button feature.
<link href="https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.css" rel="stylesheet" />
<script src="https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js"></script>
<script>
datatable = $('.datatableclass').DataTable( {
"dom": "<'row'<'col-sm-3'l><'col-sm-4'i><'col-sm-5'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-6'i><'col-sm-6'p>>",
"ajax": { ... },
buttons: [
{ extend: 'csvHtml5',
text: 'Export Table',
exportOptions: {columns: ':gt(0):visible'},
},
{ extend: 'colvis',
text: 'Columns',
columns: [2,3,4, ':gt(5)']
}
],
"headerCallback": function( thead, data, start, end, display ) {
var api = this.api();
$( api.column( 11 ).header() ).html('Billed')); // Works if this line is removed.
},
...
</script>
<table class="table datatableclass">
</table>
The code is simplified here shows the problem, but this all worked using dt v1.13
Browser console shows the following error:
Uncaught TypeError: o is undefined
_columnText https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:51
text https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:51
i https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:40
_buildButton https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:40
_expandButton https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:40
_expandButton https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:40
_expandButton https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:40
add https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:40
_constructor https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:40
A https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:40
<anonymous> https://cdn.datatables.net/v/bs/jszip-3.10.1/dt-2.1.8/b-3.2.0/b-colvis-3.2.0/b-html5-3.2.0/b-print-3.2.0/fc-5.0.4/fh-4.0.1/sl-2.1.0/datatables.min.js:40
jQuery 7
...