columns().names()

Since: DataTables 2.0.0

Get the names for the selected columns.

Description

This method is the plural version of the column().name() method, providing access to multiple column names with a single call. The returned object is a DataTables API instance which is "array-like" (i.e. it behaves like an array in Javascript).

Column names are typically set using the columns.name option and are not seen by the end user at all. They exist only to make access to the data in the table easier for the developer using the software.

Type

function columns().names()

Description:

Get the column names from the selected columns.

Returns:

API instance that contains the column names.

Examples

Get the names for all columns:

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

Determine the index of the 'salary' column:

var index = table.columns().names().indexOf( 'Salary' );
// Note that this could also be done using `column().index()` and a name selector

Related

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