column().name()

Since: DataTables 2.0.0

Get / set the name for a column.

Description

This method provides the ability to get and set a column name. Please note that the column name is hidden from the end user at all times - it is not the column title (columns.title).

Column names are primarily used to make the selection of columns more intuitive than using a number, but they can also be used for logical conditions (was it column x that was clicked upon, for example). They will typically be set at initialisation time using columns.name, but this method provides the ability for the names to be changed dynamically.

Types

function column().name()

Description:

Get the column name

Returns:

The column name. If the column doesn't have a name defined, it will be an empty string.

function column().name( value )

Description:

Set the column name

Returns:

DataTable API instance with the same column still selected.

Example

Set the name for a column and then use it as a selector:

var table = $('#example').DataTable();

table.column( 0 ).name( 'first' );

var columnData = table.column( 'first:name' ).data();

Related

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