JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head>
<title>DataTables ColumnToggle (ColVis) + ColReorder bug</title>
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.2/css/buttons.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/colreorder/1.5.5/css/colReorder.dataTables.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.2/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/colreorder/1.5.5/js/dataTables.colReorder.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.2/js/buttons.colVis.min.js"></script>
<script>
$(document).ready(function() {
$('#example').DataTable({
dom: 'Blfrtip',
colReorder: true,
buttons:[
{
extend: 'columnToggle',
columns: [".name"],
text: "Toggle name column visibility",
},
{
extend: 'columnToggle',
columns: [".position", ".office"],
text: "Toggle position + office columns visibility",
}
],
});
});
</script>
</head>
<body>
<table id="example" class="display nowrap" style="width:100%">
<thead>
<tr>
<th class="name">Name</th>
<th class="position">Position</th>
<th class="office">Office</th>
<th class="age">Age</th>
<th class="startDate">Start date</th>
<th class="salary">Salary</th>
</tr>
</thead>
...