columns.orderSequence
Order direction application sequence.
Description
You can control the default ordering direction, and even alter the behaviour of the order handler (i.e. only allow ascending sorting, reverse the default sequence, etc) using this parameter.
Values that can be given in this array are:
asc
- Ascending orderdesc
- Descending order(i.e. empty string) - data index order. Note that this option is available as of DataTables 2.0 and newer.
Prior to DataTables 2 this option defaulted to [ 'asc', 'desc' ]
. DataTables 2 added the third option to the array with the empty string included in the default for the no sort state. If you would like to use the DataTables 1.x behaviour, set the default using:
DataTable.defaults.column.orderSequence = ['asc', 'desc'];
Type
This option can be given in the following type(s):
Default
- Value:
[ 'asc', 'desc', '' ]
Examples
Using orderSequence
to define the applied order sequence with columnDefs
:
new DataTable('#myTable', {
columnDefs: [
{ orderSequence: ['asc'], targets: [1] },
{ orderSequence: ['desc', 'asc', 'asc'], targets: [2] },
{ orderSequence: ['desc'], targets: [3] }
]
});
Using orderSequence
to define the applied order sequence with columns
:
new DataTable('#myTable', {
columns: [
null,
{ orderSequence: ['asc'] },
{ orderSequence: ['desc', 'asc', ''] },
{ orderSequence: ['desc'] },
null
]
});
Related
The following options are directly related and may also be useful in your application development.