Configuring Quick Search

Summary

  • AdapTable allows users (both at run time and design time) to configure aspects of Quick Search including:
    • a custom Quick Search implementation
    • which columns and cells are included in quick search
    • whether searches are saved between sessions

Essentially Quick Search is a very straightforward operation.

It simply highlights any cells in any column which contain the matching term using a default style.

And AdapTable will re-apply an active Quick Search when the application re-opens.

However AdapTable provides many configuration options so Search can meet precise requirements.

Searching on Raw Value

By default Quick Search will return true or false if the display value in a cell contains the search text.

This means, for example, that searching for 5000 in a cell with a display value of £5,000 will return false (due to the missing comma).

As a result, sometimes this default behaviour does not meet the particular requirements.

Developers can tell Quick Search to search on the raw value, instead, by using the getCellSearchText property in Quick Search Options.

getCellSearchText

(quickSearchContext: QuickSearchContext) => boolean
Function enabling custom Quick Search implementations
Quick Search Raw Value
Fork
  • In this demo we use the getCellSearchText function to tell AdapTable to search using raw cell value on the Github Stars column
  • We provide a distinctive Number Display Format for Github Stars and Github Watchers
  • We search for "1794" and the first cell in the Github Stars is returned because it matches the raw value
Try It Out
  • Search for "667" and note that the first cell in the Github Watchers does not return a match - since that doesnt match its (default) display value

In addition to enabling searching on raw value (see section above), the getCellSearchText property in Quick Search Options also allows developers to provide their own, bespoke, Quick Search implementation.

Caution

  • A bespoke Quick Search implementation should not be provided if you are running Quick Search as a Filter
  • This is because AG Grid's native filter evaluation is used, which will be unaware of the bespoke implementation

This is particularly useful if you want to search for patterns, or across multiple cells.

Another common use case is to allow commas (or pipes) so cells containing any of the search values are returned

Hint

Bespoke Quick Search
Fork
  • In this demo we provide a bespoke Quick Search implementation by using the getCellSearchText in Quick Search Options
  • Our implementation allow users to search using comma separated values, which we achieve by changing the Quick Search Value to be that of the search text for matching cells (so it returns true)
  • We set an initial Quick Search for 'js, html' and we see that all cells which contain either of those search terms are matched
  • We also provide a CellMatchStyle in Quick Search Initial State to highlight matching cells

Caution

  • If performing a bespoke Quick Search, the up / down arrows enabling cycling through the result set will not work
  • Additionally 2 of the Quick Search Styles - TextMatchStyle & CurrentTextMatchStyle - are ignored

By default every visible Cell in AG Grid will be included in Quick Search.

This can be changed by setting the isCellSearchable function in Quick Search Options.

Hint

This is particularly useful in cases where an AG Grid Cell Component causes false positives in the Search results

isCellSearchable

(quickSearchContext: QuickSearchContext) => boolean
Function enabling specific Cells to be excluded from Quick Search

Caution

  • This function should not be provided if you are running Quick Search as a Filter
  • AG Grid's native filter evaluation will be unaware of these Cell and Column exclusions and use the full set
Quick Search Exclude Cells
Fork
  • In this demo we have provided an implementation for the isCellSearchable function in order to exclude:
    • the Description column (excluded by name)
    • any columns with a data type of Text Array (which includes the Topics column)

Saving Quick Search Text

AdapTable automatically saves the last run Quick Search value into AdapTable State.

It will then re-apply the Quick Search when the Application is next reloaded.

If this behaviour is not desired, set the clearQuickSearchOnStartUp property in Quick Search Options to true.

clearQuickSearchOnStartUp

Default: false
boolean
Clears saved Quick Search when AdapTable loads

Changing Quick Search Placeholder

The default placeholder text in each Quick Search input is Search.

This can be modified via the quickSearchPlaceholder property in Quick Search Options

quickSearchPlaceholder

Default: Search
string
Sets the placeholder used in Quick Search inputs
Quick Search Placeholder
Fork
  • In this demo we have changed the quickSearchPlaceholder to be 'Find Text'

Expand to see more

Typically Quick Search is performed using the dedicated Quick Search input.

This is available, most typically in the Dashboard, but in multiple other places in AdapTable.

However there is also an option to use Floating Quick Search.

Hint

  • This is especially useful when, for screen real estate reasons, the Dashboard and other UI components are hidden
  • Another common use case is advanced users who do everything via the keyboard and try to reduce mouse usage

The Floating Quick Search appears in the top right of the screen (similar to its position in the Dashboard).

Note

  • Floating Quick Search is opened by calling showFloatingQuickSearch in Quick Search API
  • It is closed by calling hideFloatingQuickSearch in Quick Search API or by pressing the ESC key
Floating Quick Search
Fork
  • In this demo we listen to the KeyDown Event for the key combination: 'metaKey + shiftKey + s',
  • When that happens, we open the Floating Quick Search using the showFloatingQuickSearch function in Quick Search API
  • We have hidden the Dashboard to mimic a typical use case for this functionality

Expand to see the key bindings

Try It Out
  • Click the Meta Key (windows key on PC, Command Key on Mac), Shift and 's' and see the Floating Quick Search
  • Click the Escape Key to close the Floating Quick Search

FAQ

Can we limit Quick Search to particular Cells or Column data types? Yes, you can. By default Quick Search works across ALL Cells in AdapTable. To exclude a Column or Cell, use the isCellSearchable property in Quick Search Options.