Datatable fixedColumns

by simaben

HTML

<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.js"></script>
<script src="https://cdn.datatables.net/1.11.3/js/dataTables.bootstrap.js"></script>
<script src="https://cdn.datatables.net/fixedcolumns/4.0.1/js/dataTables.fixedColumns.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap.css">
<link rel="stylesheet" href="https://cdn.datatables.net/fixedcolumns/4.0.1/css/fixedColumns.bootstrap.css">

  <table id="example">
  <thead>  <tr>
  <th>Column 1</th>
  <th>Column 2</th>
  </tr>
  </thead>
  <tbody>  
  <tr><td>1</td><td>Sent</td></tr>
  <tr><td>3</td><td>4</td></tr>
  </tbody>
  </table>
<button onClick='lockColumn(1)'>
1 Column
</button>
<button onClick='lockColumn(0)'>
0 Columns
</button>

JavaScript

function lockColumn(num) {
	table.fixedColumns().left(num);
}

  var table = $('#example').DataTable( {
        "paging":   false,
        "ordering": false,
        "info":     false,
        "fixedColumns": true,
        "initComplete": function () {
        
        }
    } );

//uncomment line 11 to see error