{hero}

orderCellsTop

Since: DataTables 1.10

Control which cell the order event handler will be applied to in a column.

Deprecated!

As of v2.0.0 this feature has been deprecated. This feature will be removed from version 3.0.0.

As of DataTables 2 the default option for this parameter has changed to null rather than the previous false in 1.x. The result is that all cells in the header will have a sort listener attached and icons shown. You can set this value to false to have the same behaviour as v1.x.

Please use titleRow as a replacement, or the data-dt-order attribute for rows / cells.

Description

Allows control over whether DataTables should use the top (true) unique cell that is found for a single column, or the bottom (false) to attach the default order listener and display sorting icons. This can be useful when using complex headers.

As of DataTables 2, if the value of this parameter is given as null (which it is by default) all cells in the header will automatically have the sort listener attached and icons shown.

Consider for example the following HTML header:

    <thead>
        <tr>
            <td rowspan="2">1</td>
            <td>2.1</td>
        </tr>
        <tr>
            <td>2.2</td>
        </tr>
    </thead>

In this case, when orderCellsTop is false the cells 1 and 2.2 will have the order event listener applied to them. If orderCellsTop is true then 1 and 2.1 will have the order event listeners applied to them. Finally, if the value is given is null (default), all cells will have the ordering event listeners attached.

Type

This option can be given in the following type(s):

Default

null

Example

Use the top cells in a complex header for ordering:

new DataTable('#myTable', {
	orderCellsTop: true
});

Related

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