{hero}

columns().titles()

Since: DataTables 2.0

Get / set the title for multiple columns.

Description

This method is used to get and set the titles of multiple columns (which are also settable at initialisation time by columns.title). The title of a column is shown in the table header. It may also be used for extra functionality such as column visibility control and export data.

DataTables wraps the column header in a span element with a class of dt-column-title. This is done to allow the get / set operation of this method, while still allowing other HTML to be present in the header cell (e.g. inline buttons).

Types

function columns().titles( [ row ] )

Description:

This method will get the titles for the selected columns

Parameters:
Returns:

The titles for the selected columns.

function columns().titles( title [, row ] )

Description:

This method will write a string as the title for multiple columns.

Parameters:
Returns:

DataTables API instance for chaining.

Example

Get the titles for all columns::

var table = new DataTable('#myTable');

var titles = table.columns().titles();

// Do something with titles...

Related

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