Search plugin provides an easy interface to perform data search across Handsontable. First thing you should do, is enabling the plugin by setting the search
option to true
. When enabled, searchPlugin exposes a new method query(queryStr), where queryStr
is a string to find within the table. By default, the search is case insensitive.
By default searchPlugin
adds htSearchResult
class to every cell which isSearchResult
property is true
. You can change this class using searchResultClass
option. If you wish to change the result class globally (for all Handsontable instances on the page), you can use Handsontable.Search.global.setDefaultSearchResultClass(className)
method.
The queryMethod
is responsible for determining whether a queryStr
matches the value stored in a cell. It takes 2 arguments: queryStr
and cellData
. The first is a string passed to query()
method. The second is a value returned by getDataAtCell()
. The queryMethod
function should return true if there is a match.
After calling queryMethod
, searchPlugin
calls callback(instance, rowIndex, colIndex, cellData, testResult)
for every cell. The default callback is responsible for setting the isSearchResult
property, so if you want to preserve this functionality, be sure to invoke Handsontable.Search.DEFAULT_CALLBACK
inside your custom callback.
0 results found