{hero}

column().type()

Since: DataTables 2.0

Get a column's data type.

Description

This method can be used to get the data type for a given column. A data type can be set at initialisation time using the columns.type option, or through the preferred automatic type detection that is run on data.

This can be useful for extensions when working with a specific column - e.g. knowing what the data type is for search data can be important.

There is no setter for this method. Rather, when data is set for a column (row().data(), row.add(), etc), the column type is invalidated and then recalculated when it is next needed. The recalculation will either take the value from columns.type if specified, or run the automatic type detection of the column's data again.

Please note that since DataTables 2.1 automatic type detection is not attempted on tables which have server-side processing enabled (serverSide). This is because the full data set is not available for type detection, thus resulting in unreliable and error prone automatic type detection. If you need type specific actions when working with server-side processing, you must explicitly set the type using columns.type.

Type

function column().type()

Description:

Get the configured or automatically detected data type for a column.

Returns:

Data type detected for a column.

Example

Get the data type for a column that was clicked on:

let table = new DataTable('#example');

$('#example').on('click', 'tbody td', function () {
	let type = table.cell(this).type();

	alert('Data type: ' + type);
});

Related

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