Default ordering
With DataTables you can alter the ordering characteristics of the table at initialisation time. Using the order initialisation parameter, you can set the table to display the data in exactly the order that you want. The order parameter is an array of arrays where the first value of the inner array is the column to order on, and the second is 'asc' or 'desc' as required. The table below is ordered (descending) by the DOB column.
Multi column ordering
DataTables allows ordering by multiple columns at the same time, which can be activated in a number of different ways: - user shift click on a column; - on a per-column basis; - using the columns.orderData option. The example below shows the first column having a secondary order applied to the second column in the table, vice-versa for the second column being tied directly to the first and the salary column to the first name column.
Order direction sequence control
At times you may wish to change the default ordering direction sequence for columns to be 'descending' rather than default ascending. This can be done through the use of the columns.orderSequence initialisation parameter. The example below shows: Columns 1, 2 - default ordering; Column 3 - ascending ordering only; Column 4 - descending ordering, followed by ascending and then ascending again; Column 5 - descending ordering only.
Complex headers with sorting
Complex headers (using colspan / rowspan) can be used to group columns of similar information in DataTables, creating a very powerful visual effect. In addition to the basic behaviour, DataTables can also take colspan and rowspans into account when working with hidden columns. The example below shows a header spanning multiple cells over the contact information with sorting, with one of the columns that the span covers being hidden.