#Grid Filter
The grid filter is a single AdaptableQL boolean expression that
every row must satisfy to be shown. Unlike a column filter,
it can reference any number of columns, combine conditions with AND /
OR, and put several conditions on the same column.
The grid filter is part of the view — set it in the table view's
filters.grid:
const state: AdaptableUserState = {
view: {
currentViewId: 'typescript-or-senior',
views: [
{
id: 'typescript-or-senior',
label: 'TypeScript or salary > 150k',
filters: { grid: '[preferredLanguage] = "TypeScript" OR [salary] > 150000' },
},
],
},
};The grid filter and the column filters work together: a row is shown only when it passes the grid filter and every column filter. Grid filters apply to table views only — pivot views have none.
The expression may use aggregations, which are computed over all rows — so
[salary] > AVG{[salary]} keeps the rows with an above-average salary.
Two views, each with its own grid filter. Switch views in the view picker and watch the row count; edit the expression in the grid filter input of the dashboard.
#Pausing the grid filter
A paused grid filter stays in the view but doesn't hide any row. Pause it with
filters.paused.grid: true, from the settings panel, or with
adaptableApi.filterApi.setGridFilterPaused(true).
#Named queries
A named query is a reusable AdaptableQL expression, stored in the
namedQuery state slice and referenced from other expressions as
QUERY("name") (names are case-insensitive). A grid filter can be a named
query, or combine one with other conditions:
const namedQueryState: AdaptableUserState = {
namedQuery: {
'high-earners': {
name: 'HighEarners',
expression: '[salary] > 120000',
description: 'Developers earning more than 120k',
},
},
view: {
currentViewId: 'default',
views: [
{
id: 'default',
label: 'High earners outside the USA',
filters: { grid: 'QUERY("HighEarners") AND [country] != "USA"' },
},
],
},
};When the named query changes, every grid filter that references it re-runs. Named queries are evaluated per row, so they can't contain aggregations.
The grid filter references the HighEarners named query. Open the settings
panel, go to Named Queries and change the salary threshold — the grid
re-filters.
#Editing the grid filter
The grid-filter dashboard widget shows the current view's
grid filter as an inline expression input.
The Filter page of the settings panel edits the grid
filter and the column filters of the current view. For
the grid filter, users can edit the expression inline or in the full editor,
pause, resume or clear it, save it as a named query (the filter then
becomes a QUERY("name") reference, so editing the query updates the filter),
or apply an existing named query.
The page is also available standalone as <adaptable-view-grid-filter-editor>,
and you can replace it in the settings panel with your own component (a
component class or a template) through components.ViewGridFilterEditor of
<adaptable-provider>.
#Building your own filter UI
injectGridFilter() reads and writes the current view's grid filter. Call it
in a component rendered inside <adaptable-provider>; it returns one signal of
an object: read it as gridFilter(), in the class and in the template.
import { injectGridFilter } from '@adaptabletools/datagrid-angular';
// a component rendered inside <adaptable-provider>
@Component({ selector: 'my-grid-filter', template: `<!-- ... -->` })
class MyGridFilter {
// a signal: read it where you use it, so it is always current
private readonly gridFilterModel = injectGridFilter();
onSomeEvent() {
const {
isTableView, // grid filters apply to table views only
gridFilter, // the current expression, '' when none
setGridFilter, // (expression | undefined) => void — '' removes it
clearGridFilter,
isPaused,
setPaused, // (paused) => void
isValidGridFilter, // (expression) => boolean
} = this.gridFilterModel();
// ...
}
}The input above the grid is a component built with injectGridFilter(). Type
an expression such as [country] = "Japan" OR [salary] < 80000 and press
Apply — invalid expressions are outlined in red. Pause keeps the filter
but shows every row.
Imperatively, use adaptableApi.filterApi.setGridFilter(expression). You can
also drive the grid filter through controlled state: bind
[(state)] on <adaptable-provider> and write filters.grid of the current
view yourself.