Filtering Quick Search Results
Summary
- AdapTable can be configured to filter AG Grid to match search results
- This can be an expensive operation so use with care
By default Quick Search provides Find and Highlight functionality only.
However, there is an option also to filter the grid using the same search results.
Caution
- This comes with some important caveats regarding performance and implementation - see below
- Use this option with great care - we recommend filtering the Grid using Column Filters or Grid Filter
This is done by setting the filterGridAfterQuickSearch property in Quick Search Options.
Hint
Run-time users can enable / disable this via Filter Quick Search Results checkbox in Quick Search Settings Panel
filterGridAfterQuickSearch
Default: falsebooleanWhen running Quick Search as Filter rows are only displayed if they:
- are leaf rows (i.e. are not grouped rows)
- contain at least one currently visible column that includes the search text (and that Column has not been explicitly excluded from Quick Search)
- Here we run a Quick Search (on the word 'typescript') but filtering the results
- AdapTable, therefore, only displays matching rows (as well as highlighting matching cells)
Caveats
Quick Search as Filter directly leverages AG Grid's native Quick Filter functionality.
Note
It does not use AdapTableQL which is used to power AdapTable's Column Filters and Grid Filter capabilities
This can cause a few issues which you should take into consideration before using this property.
Large Data
Quick Search as Filter can be an expensive operation particularly if the Grid contains a very large data set.
This is because each cell is individually evaluated, with no default caching.
Hint
With large data, Quick Search as Filter performance can be improved by enabling AG Grid's Quick Filter Cache
Bespoke Quick Search
Another caveat is that Quick Search as Filter does not work very well if a bespoke Quick Search implementation has been provided.
This is because AG Grid wil not know about this custom Quick Search implementation, and will therefore work with a different "result set" to that provided by Quick Search.
Searchable Cells
AdapTable provides the ability for users to configure which cells and columns are searchable using the isCellSearchable property in Quick Search Options.
This property is also ignored when using Quick Search as Filter since, again, AG Grid does not know about these exclusions, and will therefore work with full Column set regardless.
Server-Side Row Model
When using the Server-Side Row Model, all filtering is implemented by developers in a bespoke fashion.
This means that if you wish to use Quick Search as Filter, you will need to implement the Filtering part yourself.
Quick Filter Parser Behaviour
The default behaviour for the AG Grid Quick Filter is to return rows that contain any of the search string.
Note
- For example, searching for "Hello World" would return a cell which contained the text "Hello, I'm at PC World"
- However, AdapTable will not highlight this cell - with the result that some rows will display with no highlighted cells
This can be "fixed" by changing the quickFilterParser property in Grid Options.
- In this example we run a Quick Search with Filter on the text "Very Good"
- AG Grid's Quick Filter also returns "Very New but Good" and "Very Well Liked with Good Results"
- A Dashboard button has been added which changes this default behaviour so that only an exact string is returned
- This is done by updating the
quickFilterParserproperty:agGridApi.setGridOption('quickFilterParser', filterStr => [filterStr]);
- Click the Dashboard button and note that now only the 2 Rows with Highlights are filtered
FAQ
Why is Quick Search as Filter running slowly with 100K Rows and 50 Columns? Quick Search as Filter evaluates every cell so it can be an expensive operation when running against millions of cells. Both Column Filters and Grid Filter are optimised for working with large data and will be far more performant.