splice()
Modify the contents of an Api instance's result set, adding or removing items from it as required.
Description
The methods of pop()
, shift()
etc can be useful to modify an Api instance's result set, but they are restricted to operating at the start of the end of the result set. This method can be used to modify the result set at any point.
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.
In this case, this method is a proxy for the Javascript Array.prototype.splice
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 splice
.
Type
function splice( index, howMany [, value_1 [, ... ] ] )
- Description:
Modify the contents of an Api instance's result set, adding or removing items from it as required.
- Parameters:
Name Type Optional 1 index
No Index at which to start modifying the Api instance's result set.
2 howMany
No Number of elements to remove from the result set. This can be 0 if you wish to only add new items.
3 value_1
Any
Yes Item to add to the result set at the index specified by the first parameter. Multiple items can be added in a single call by adding them as additional parameters.
- Returns:
An array of the items which were removed. If no elements were removed, an empty array is returned.