column().type()
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.
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.