Since: DataTables 1.10

Set column definition initialisation properties.


Very similar to columns, this parameter allows you to assign specific options to columns in the table, although in this case the column options defined can be applied to one or more columns. Additionally, not every column need be specified, unlike columns.

This parameter is an array of column definition objects, where the options available exactly match those for columns (see below for list of options in the related links).

In addition to the column property options, columnDefs requires a targets property to be set in each definition object (columnDefs.targets). This targets property tells DataTables which column(s) the definition should be applied to. It can be:

  • 0 or a positive integer - column index counting from the left
  • A negative integer - column index counting from the right
  • A string - class name will be matched on the TH for the column
  • The string _all - all columns (i.e. assign a default)

Additionally, targets can be either a single option from the list above, or an array of options (the different types can be mixed in the array if required). For example targets: [ -1, -2 ] would target the last and second last columns in the table.

Conflict resolution

As columnDefs allows columns to be defined one or more times in different column definition objects (typically to define different aspects of the columns) conflicts can arise whereby a single property might be defined with different values for the same column. Likewise, this situation could also occur when columns is used at the same time. DataTables uses the following rules to resolve such conflicts:

  1. A property defined in columns will always take priority over any value for that property defined in columnDefs.
  2. Properties which are higher in the columnDefs array will take priority over those below.

Consider for example the following table:

var table = $('#myTable').DataTable( {
    columnDefs: [
        { targets: [0, 1], visible: true},
        { targets: '_all', visible: false }
} );

The first and second columns will be visible in the table while all others will be hidden.


This option can be given in the following type(s):


Disable filtering on the first column:

$('#example').dataTable( {
  "columnDefs": [ {
      "targets": 0,
      "searchable": false
    } ]
} );


The following options are directly related and may also be useful in your application development.