columns().data()

Since: DataTables 1.10

Get the data for the cells in the selected columns.

Description

This method is used to get the data used for the cells in the columns matched by the selector from DataTables.

Please note that the order of the data in the returned array and which rows the data is obtained from (searched rows, visible rows etc) is controlled by the selector-modifier option of the columns() selector used to get the selected columns.

Type

function columns().data()

Description:

Obtain the data for the columns from the selector

Returns:

DataTables API instance with data for each cell in the selected columns in the result set. This is a 2D array with the top level array entries for each column matched by the columns() selector.

Examples

Get a list of the unique data, sorted, from a single column:

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

$('#listData').html( 
	table
		.columns( 0 )
		.data()
		.eq( 0 )      // Reduce the 2D array into a 1D array of data
		.sort()       // Sort data alphabetically
		.unique()     // Reduce to unique values
		.join( '<br>' )
);

Check if a value is in the data in the columns with a class of '.check':

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

var idx = table
	.columns( '.check' )
	.data()
	.eq( 0 ) // Reduce the 2D array into a 1D array of data
	.indexOf( 'Yes' );

if ( idx === -1 ) {
	alert( 'Yes not found' );
}
else {
	alert( 'Yes was found' );
}

Related

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