{hero}

column().data()

Since: DataTables 1.10

Get the data for the cells in the selected column.

Description

This method is used to get the data used for the cells in the column 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 column() selector used to get the selected column.

Additionally, if the selector used in column() matches more than one column, the result set will be truncated to a single column - the first one in the result set.

Type

function column().data()

Description:

Obtain the data for the column from the selector

Returns:

DataTables API instance with data for each cell in the selected columns in the result set. This is a 1D array with each entry being the data for the cells from the selected column.

Example

Sum the data for column 4:

var table = new DataTable('#myTable');

alert(
	'Column 4 sum: ' +
		table
			.column(4)
			.data()
			.reduce(function (a, b) {
				return a + b;
			})
);

Related

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