Search

The search plugin provides an easy interface to search data across Handsontable.

In order to enable search mechanism, Options#search option must be set to true.

Example
// as boolean
search: true
// as a object with one or more options
search: {
  callback: myNewCallbackFunction,
  queryMethod: myNewQueryMethod,
  searchResultClass: 'customClass'
}

// Access to search plugin instance:
const searchPlugin = hot.getPlugin('search');

// Set callback programmatically:
searchPlugin.setCallback(myNewCallbackFunction);
// Set query method programmatically:
searchPlugin.setQueryMethod(myNewQueryMethod);
// Set search result cells class programmatically:
searchPlugin.setSearchResultClass(customClass);

Classes

Search

Methods

destroy()

Destroys the plugin instance.

disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin()

Enables the plugin functionality for this Handsontable instance.

getCallback(){function}

Gets the callback function.

Returns: {function} Return the callback function.

getQueryMethod(){function}

Gets the query method function.

Returns: {function} Return the query method.

getSearchResultClass(){string}

Gets search result cells class name.

Returns: {string} Return the cell class name.

isEnabled(){boolean}

Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit
hook and if it returns true than the AutoRowSize#enablePlugin method is called.

Returns: {boolean}

query(queryStr, callback, queryMethod){Array.<object>}

Makes the query.

Parameters:
Name Type Description
queryStr string

Value to be search.

callback function optional

Callback function performed on cells with values which matches to the searched query.

queryMethod function optional

Query function responsible for determining whether a query matches the value stored in a cell.

Returns: {Array.<object>} Return an array of objects with row, col, data properties or empty array.

setCallback(newCallback)

Sets the callback function. This function will be called during querying for each cell.

Parameters:
Name Type Description
newCallback function

A callback function.

setQueryMethod(newQueryMethod)

Sets the query method function. The function is responsible for determining whether a query matches the value stored in a cell.

Parameters:
Name Type Description
newQueryMethod function

A function with specific match logic.

setSearchResultClass(newElementClass)

Sets search result cells class name. This class name will be added to each cell that belongs to the searched query.

Parameters:
Name Type Description
newElementClass string

CSS class name.

updatePlugin()

Updates the plugin state. This method is executed when Core#updateSettings is invoked.

Class: Search