column().order()
Order the table by the selected column.
Description
This method provides a useful alternative to the order()
method, allowing you to select the column that you want to be ordered using the flexible column()
selector and having it ordered in the direction specified.
Note that if the selector used for column()
matches more than one column, the result will be truncated to a single column. To perform multi-column ordering, please use columns().order()
or order()
.
Please be aware that this method sets the ordering to apply to the table - it does not actually perform the order. In order to have the order performed, use the draw()
method, which can be called simply as a chained method of the order()
method's returned object - for example table.order([0, 'desc']).draw();
.
Type
Example
Sort by the first visible column:
var table = $('#example').DataTable();
table
.column( '0:visible' )
.order( 'asc' )
.draw();
Related
The following options are directly related and may also be useful in your application development.