column().search.fixed()
Get / set a named search to apply to a column.
Description
Just as search.fixed()
applies a "fixed" search term to the whole table, this method can be used to apply a search term to a specific column.
The fixed search (which might also be termed sticky or named searches) provides a way to easily add cumulative search terms to the table. You can add multiple independent search terms, and DataTables will combine them (AND logic) displaying the result of all search terms that have been applied.
Please be aware that this method sets the fixed search to apply to the column only - it does not actually perform the search. In order to have the search performed and the result shown, use the draw()
method, which can be called simply as a chained method of this method.
Types
column().search.fixed()
Get a list of the names of searches applied to the column.
Returns:
DataTables.Api
An API instance that contains the names of the search terms applied to the column.
column().search.fixed( name )
Get the search term used for the given name.
Returns:
undefined
or function
or string
or RegExp
The search term that was originally applied.
column().search.fixed( name, searchTerm )
Parameters:
Name | Type | Optional | |
---|---|---|---|
1 | name | No | |
Treat as a regular expression ( | |||
2 | input | No | |
The search term to apply to the table. Use If given as a string, it will be applied to the table's search using DataTables "smart" search (see If working with a regular expression, the data given is the search data for the cells in column in question. In the case of a function the function is called for each row with four parameters which are passed in:
A boolean value should be returned: |
Returns:
DataTables.Api
DataTables API instance
Examples
Get an array of current search names:
let table = new DataTable('#myTable');
let searches = table
.column(0)
.search.fixed()
.toArray();
Get an expecting search term:
let search = table.column(1).search.fixed('mySearch');
Applying a search string:
table.column('.cities').search.fixed('myString', 'Paris');
Applying a search regex:
table.column(0).search.fixed('myRegex', /l.*n/i);
Applying a search function:
table.column(-1).search.fixed('myFunc', (cell, data) => {
return cell > 50;
});
Deleting an existing search term:
table.column(0).search.fixed('mySearch', null);
Related
The following options are directly related and may also be useful in your application development.