Adaptable

#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' }],
  },
};

#What quick search looks at

  • Every text, number, date and boolean column 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 — java matches JavaScript.
  • 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.

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.

#
Quick search styles

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.

open
loading demo…

#Row groups

Quick search works on grouped views too: group rows are searched as well, including their aggregated values.

#
Quick search in row groups

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.

open
loading demo…
Note

Quick search is not available in pivot views — the search input is disabled while a pivot view is active.

#Quick search state

PropertyDescriptionDefault
activeCellStylestyle of the active cellpale yellow background
activeTextStylestyle of the matching text in the active cell—
disableNavigationturns off navigating between matchesfalse
highlightCellStylestyle of a cell with a match—
highlightTextStylestyle of the matching textpale yellow background
quickSearchDebounceTimemilliseconds to wait after the last keystroke250
searchPlaceholderplaceholder of the search input'Search'
searchTextthe text being searched for—

The styles are AdaptableCellStyle objects: background, color, borderColor, fontWeight, fontStyle, textDecoration, fontSize, and alignment.

#Quick search in the UI

  • The quickSearch dashboard widget is the search input, as in the demos above.
  • Adaptable.UI.QuickSearch renders 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 composable reads and updates everything but the search text. It returns one ComputedRef of { config, updateConfig }:

<script setup lang="ts">
import { useQuickSearchConfig } from '@adaptabletools/datagrid-vue';

// a ComputedRef: read it through `.value` here, directly in the template
const quickSearch = useQuickSearchConfig();

function onChange(event: Event) {
  quickSearch.value.updateConfig({
    disableNavigation: !(event.target as HTMLInputElement).checked,
  });
}
</script>

<template>
  <label>
    <input type="checkbox" :checked="!quickSearch.config.disableNavigation" @change="onChange" />
    Navigate between matches
  </label>
</template>

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, …).