{hero}

includes()

Since: DataTables 2.0

Determine if an API result set contains a given value.

Description

You may find it useful to know if an API instance's result set contains a particular value. While that can be achieved readily with indexOf(), this utility method can be a useful short-cut if you don't need to know the value's location in the result set.

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

Type

function includes( value )

Description:

Determine if a result set contains the value given.

Parameters:
Returns:

true if found, false if not.

Example

Check if a value is visible on the current page:

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

var found = table
	.column(0, { page: 'current' })
	.data()
	.includes(21);

if (found) {
	alert('21 was not found in the result set');
}
else {
	alert('21 was found at index: ' + index);
}

Related

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