column().orderable()
Get information about the orderable status of a column.
Description
This method provides the ability to programmatically check if a given column is orderable by the end user (a click on the header cell) and optionally to get the ordering directions that the column can take, as defined by columns.orderSequence.
Type
column().order( [ directions ] )
Get information about the orderable status of a column (enabled or not and what ordering directions are available).
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | directions | Yes - default:false | |
Controls the information that is returned - see below for details. Can be not given (undefined), | |||
Returns:
DataTables.Api: DataTables API instance containing true or false depending on the column's orderable state if directions is undefined or false. If the parameter passed in is true the method will return information about what ordering directions this column can take (see columns.orderSequence).
Example
Check if the first column is orderable by the end user, and if so, order on it:
var table = new DataTable('#myTable');
if (table.column(0).orderable()) {
table
.column(0)
.order()
.draw();
}Related
The following options are directly related and may also be useful in your application development.