titleRow

Since: DataTables 2.3

Control which row in the header is the title row.

Description

This option can be used to control how DataTables which cells in a table header are treated as a "title cell". This is relevant when multiple rows are used in the table header, particularly with colspan and rowspan

Title cells are used for the following in DataTables:

You can give this option as one of several values:

  • A number - this will specify the row index in the header that is used for the above.
  • true - the cells in the top row (index 0) will be used for the title cells
  • false - the cells in the bottom row will be used for the title cells
  • null (default) - all cells will be used for ordering operations, and the first unique cell (i.e. colspan=1) will be used for the column title.

Types

null

All cells in the header will be treated as title cells, with each receiving ordering icons and click to order actions (dependent on columns.orderable), unless the cell has the attribute data-dt-order="disable".

number

Specify the row index (i.e. the tr index in the thead) that will be used for the title row.

boolean

If true the first row in the header will be treated as the title row. If false the bottom row in the header will be treated as the title row.

Default

null

Examples

Use the first row in the header as the title row:

new DataTable('#myTable', {
	titleRow: 0
});

Use the second row in the header as the title row:

new DataTable('#myTable', {
	titleRow: 1
});

Related

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