{hero}

columns().search.fixed()

Since: DataTables 2.0

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 columns 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.

When using server-side processing, additional logic must be added at the server-side to handle fixed search terms. Additionally, searching by functions is not possible, since the search function is client-side based.

Types

function columns().search.fixed()

Description:

Get a list of the names of searches applied to the selected columns.

Returns:

An API instance that contains the names of the search terms applied to the columns.

function columns().search.fixed( name )

Description:

Get the search term used for the given name.

Returns:

The search term that was originally applied.

function columns().search.fixed( name, searchTerm )

Description:
Parameters:
Returns:

DataTables API instance

Examples

Get an array of current search names from all columns:

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

let searches = table
	.columns()
	.search.fixed()
	.toArray();

Get an expecting search term:

let search = table.columns([1, 4]).search.fixed('mySearch');

Applying a search string:

table.columns('.cities').search.fixed('myString', 'Paris');

Applying a search regex to column indexes 0 and 1:

table.columns([0, 1]).search.fixed('myRegex', /l.*n/i);

Applying a search function to multiple columns:

table.columns('.number').search.fixed('myFunc', (cell, data) => {
	return cell > 50;
});

Deleting an existing search term from all columns:

table.columns().search.fixed('mySearch', null);

Related

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