unique()

Since: DataTables 1.10

Create a new API instance containing only the unique items from a the elements in an instance's result set.

Description

It is often useful to know what data is available in a result set, with duplicate items removed (for example creating a select list for use as a search input). Although unique items can be found quite trivially with a loop, this utility function provides that ability for you in one simple method.

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 unique()

Description:

Create a new API instance containing only the unique items from a the elements in an instance's result set.

Returns:

New Api instance which contains the unique items from the original instance's result set, in its own result set.

Example

Get the unique data from a column:

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

table
	.column( 0 )
	.data()
	.unique();