Skip to content

Boolean Filter

The Boolean Filter adds dedicated, valueless operators for columns whose source values are boolean primitives. By default, users see Yes and No in the advanced-filter popup.

Add AdvanceFilterPlugin, then assign FILTER_BOOLEAN to the column:

import {
AdvanceFilterPlugin,
FILTER_BOOLEAN,
} from '@revolist/revogrid-pro';
grid.plugins = [AdvanceFilterPlugin];
grid.columns = [
{
name: 'Enabled',
prop: 'enabled',
filter: [FILTER_BOOLEAN],
},
];
grid.source = [
{ enabled: true },
{ enabled: false },
];

The string form is equivalent:

{
name: 'Enabled',
prop: 'enabled',
filter: ['boolean'],
}

The displayed names and stored operator keys are intentionally separate:

Default nameOperator keyMatches
YesisTrueThe boolean primitive true
NoisFalseThe boolean primitive false

The filter uses strict boolean matching. Values such as 'true', 'false', 1, 0, null, and undefined are not coerced into boolean matches.

Use defineAdvancedFilterConfig to change the displayed operator names. The operator keys remain isTrue and isFalse, so saved filter models and matching behavior do not change.

import {
defineAdvancedFilterConfig,
} from '@revolist/revogrid-pro';
grid.filter = defineAdvancedFilterConfig({
localization: {
filterNames: {
isTrue: 'Enabled',
isFalse: 'Disabled',
},
},
});

Labels can use any application-specific wording, such as Active / Inactive or localized translations.

Use the stable operator keys when restoring or sending a filter model:

grid.filter = defineAdvancedFilterConfig({
multiFilterItems: {
enabled: [
{
id: 0,
type: 'isTrue',
relation: 'and',
},
],
},
});