datatable column width fixed code example

Example 1: fixed table header datatables

$(document).ready(function() {
  var table = $('#myapproval').DataTable( {
      "fixedHeader": { 
      "header": true, 
      "footer": false 
      }
  }
}

Example 2: datatables change width of columns

$('#example').dataTable( {
  "autoWidth": false, // might need this
  "columns": [
    { "width": "20%" },
    null, // automatically calculates
    null  // remaining width
  ]
} );

Example 3: datatable column width

columnDefs: [
            { width: 200, targets: 0 }
        ],

Example 4: datatable width column

table.display {
  margin: 0 auto;
  width: 100%;
  clear: both;
  border-collapse: collapse;
  table-layout: fixed;         // add this 
  word-wrap:break-word;        // add this 
}

Tags:

Misc Example