{hero}

unshift()

Since: DataTables 1.10

Add one or more items to the start of an API instance's result set.

Description

Just as with Javascript arrays', since the DataTables API object is "array like", items can be added to a result set using this method. Unshifting an item onto an API instance adds it to the start of the result set. Items can be added at the end of the result set using push() if required.

This method is a proxy for the Javascript Array.prototype.unshift method and is provided as a utility method for the DataTables API. For more information about the original method, please refer to the Mozilla MDN documentation for unshift.

Type

function unshift( value_1 [, value_2 [, ...] ] )

Description:

Add one or more items to the start of an API instance's result set.

Parameters:
Returns:

The length of the modified API instance

Example

Add an empty string to the array returned from a column's data (might be useful for building a search list for example):

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

var data = table.column(0).data();

data.unshift('');