columns.orderData

Since: DataTables 1.10

Define multiple column ordering as the default order for a column.

Description

Allows a column's sorting to take multiple columns into account when doing a order.

For example with first name / last name columns next to each other, it is intuitive that they would be linked together to multi-column sort.

Types

integer

Description:

A single column index to order upon

array

Description:

Multiple column indexes to define multi-column sorting

Default

Takes the index value of the column automatically

Examples

Using orderData to define multi-column sorting with columnDefs:

$('#example').dataTable( {
  "columnDefs": [
    { "orderData": [ 0, 1 ],    "targets": 0 },
    { "orderData": 0,           "targets": 1 },
    { "orderData": [ 2, 3, 4 ], "targets": 2 }
  ]
} );

Using orderData to define multi-column sorting with columns:

$('#example').dataTable( {
  "columns": [
    { "orderData": [ 0, 1 ] },
    { "orderData": 0, },
    { "orderData": [ 2, 3, 4 ] },
    null,
    null
  ]
} );

Related

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