#Quick Search
Quick search finds the cells that contain a piece of text, across all columns of the grid, and highlights them. Users can step through the matches one by one.
Quick search highlights matches — it doesn't hide rows. To show only the rows that match, use column filters or the grid filter.
The search text and the quick search settings live in the
quickSearch state slice:
const state: AdaptableUserState = {
quickSearch: {
searchText: 'java',
},
dashboard: {
top: {
widgets: [{ id: 'quick-search', type: 'quickSearch', align: 'end' }],
},
},
view: {
currentViewId: 'default',
views: [{ id: 'default', label: 'Default' }],
},
};The grid opens with a search for java, which matches both Java and
JavaScript in the language column. Use the arrows in the search input (or
the up and down keys) to move through the matches.
#What quick search looks at
- Every
text,number,dateandbooleancolumn of the current view, including calculated columns and group rows. Columns of other data types (e.g.array) are not searched. - The match is a case-insensitive "contains" on the cell value —
javamatchesJavaScript. - The list of matches is rebuilt when the search text changes, when the data changes, and when the grid is sorted, filtered or grouped.
#Highlight styles
Two styles decide how matches look:
highlightTextStyle— the matching text inside a cell. Defaults to a pale yellow background.highlightCellStyle— the whole cell that contains a match. No default.
A cell style is useful when cells hold a lot of text and the matching part may be cut off.
#Navigating results
The quick search input shows up and down arrows next to the text once there
are matches. Moving to a match scrolls it into view and marks it as the
active match. In the input, the up and down keys (and Enter /
Shift+Enter) move between matches, and Escape clears the search.
The active match has its own two styles, which take precedence over the highlight styles:
activeTextStyle— the matching text of the active cell. No default.activeCellStyle— the active cell. Defaults to a pale yellow background.
Set disableNavigation: true to hide the arrows and turn navigation off; the
active styles are not used then.
Matching cells get an orange border and the matching text an orange background.
Step through the matches with the arrows — the active cell turns light blue,
with its matching text in purple. The input above the grid is the standalone
Adaptable.UI.QuickSearch component.
#Row groups
Quick search works on grouped views too: group rows are searched as well, including their aggregated values.
The view is grouped by language, with the salaries summed per group. The search
for 580 matches the salary total of the TypeScript group — no single
salary contains it.
Quick search is not available in pivot views — the search input is disabled while a pivot view is active.
#Quick search state
| Property | Description | Default |
|---|---|---|
activeCellStyle | style of the active cell | pale yellow background |
activeTextStyle | style of the matching text in the active cell | — |
disableNavigation | turns off navigating between matches | false |
highlightCellStyle | style of a cell with a match | — |
highlightTextStyle | style of the matching text | pale yellow background |
quickSearchDebounceTime | milliseconds to wait after the last keystroke | 250 |
searchPlaceholder | placeholder of the search input | 'Search' |
searchText | the text being searched for | — |
The styles are AdaptableCellStyle objects: background, color,
borderColor, fontWeight, fontStyle, textDecoration, fontSize, and
alignment.
#Quick search in the UI
- The
quickSearchdashboard widget is the search input, as in the demos above. Adaptable.UI.QuickSearchrenders the same input anywhere inside the Provider — in your own toolbar, for example.- The Quick Search page of the settings panel sets the placeholder, debounce, navigation and the four styles, with a live preview.
For custom settings UIs, the useQuickSearchConfig hook reads and updates
everything but the search text:
import { useQuickSearchConfig } from '@adaptabletools/datagrid-react';
function QuickSearchOptions() {
const { config, updateConfig } = useQuickSearchConfig();
return (
<label>
<input
type="checkbox"
checked={!config.disableNavigation}
onChange={(event) =>
updateConfig({ disableNavigation: !event.target.checked })
}
/>
Navigate between matches
</label>
);
}updateConfig merges the patch into the config; undefined, '' and {}
values remove a setting from the state.
To set the search text from code, use adaptableApi.quickSearchApi.setSearchText(text)
— getSearchText() reads it back. quickSearchApi also has setters for the
styles and the other settings (setHighlightTextStyle, setActiveCellStyle,
setQuickSearchDebounceTime, setNavigationEnabled, …).