flatten()

Since: DataTables 1.10

Flatten a 2D array structured API instance to a 1D array structure.

Description

This method will reduce a 2D array structure to a simple 1D structure, which can be particularly useful when working with the plural methods such as rows() and columns() which can return 2D structures data (for example in the columns data, each column has its own array of information).

This method makes use of the fact that DataTables API objects are "array like", in that they inherent a lot of the abilities and methods of the Javascript Array type.

Type

function flatten()

Description:

Reduce a 2D array structured API instance to a 1D array structure.

Returns:

New API instance with the 2D array values reduced to a 1D array.

Example

Get the data from two columns in a single array:

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

var data = table
	.columns( [0, 1] )
	.data()
	.flatten();