When I set a column to "noVis" it does not get applied until after a column re-order event.
When I set a column to "noVis" it does not get applied until after a column re-order event.
Link to test case:
Debugger code (debug.datatables.net): ixubat
Error messages shown:
Description of problem: On initial page load the first column should not be in the column visibility list, as it is given the "noVis" class in the table setup. If I drag a column into a different order it will fix the problem as the first column disappears from the dropdown. As long as the columns are not in the original order then the column will not be listed in the dropdown. But if I drag the columns into the original order and navigate away from the page, when I come back the first column will be listed in the dropdown again.
Here is the table setup:
$('#ppe_table').dataTable( {
stateSave: true,
stateDuration: 0,
dom: '<"toolbar">Bfrtip',
colReorder: true,
buttons: [
{ extend: 'colvis', position: 'dropdown', columns: ':not(.noVis)',
className: "btn btn-xs btn-brand dropdown-toggle", dataToggle: "dropdown", ariaExpanded: "false"},
{ extend: 'copy', className: 'btn btn-xs btn-brand' },
{ extend: 'print', className: 'btn btn-xs btn-brand' },
{ extend: 'csv', className: 'btn btn-xs btn-brand' },
{ extend: 'excel', className: 'btn btn-xs btn-brand' }
],
inputType: 'search',
name: 'search',
"oLanguage": {
"sSearch": "Filter: "
},
search: {
search: '<%= raw(@filter) %>'
},
"order": [[ 1, "asc" ]],
"columnDefs": [
{"targets": [0], "orderDataType": "dom-checkbox"},
{"targets": [0], "className": "noVis"}
],
scrollY: 550,
scrollX: true,
scrollCollapse: true,
paging: false,
fixedHeader: {
header: true,
footer: true
},
"initComplete": function(settings, json) {
if (getParam() !== 'undefined') {this.api().search(getParam()).draw();}
}
} );
No idea why it's reverting the column list when they are in the original order. This happens on multiple tables I have set up.