Skip to content

Filter Selection Cascade

Use filter.selection.cascadeOptions.enabled to make selection options context-aware.

In cascade mode, RevoGrid builds each column’s selection list from rows matching all active filters except filters for the current column. This keeps the current column reversible while still narrowing options in related columns.

Source code
import { defineCustomElements } from '@revolist/revogrid/loader';
import { AdvanceFilterPlugin, ColumnStretchPlugin } from '@revolist/revogrid-pro';
import { currentTheme } from '../composables/useRandomData';
defineCustomElements();
const rows = [
{ country: 'Germany', city: 'Berlin', department: 'Sales' },
{ country: 'Germany', city: 'Munich', department: 'Engineering' },
{ country: 'France', city: 'Paris', department: 'Sales' },
{ country: 'France', city: 'Lyon', department: 'Support' },
{ country: 'Poland', city: 'Warsaw', department: 'Engineering' },
{ country: 'Poland', city: 'Krakow', department: 'Support' },
];
export function load(parentSelector: string) {
const grid = document.createElement('revo-grid');
grid.columns = [
{ name: 'Country', prop: 'country', filter: ['selection'] },
{ name: 'City', prop: 'city', filter: ['selection'] },
{ name: 'Department', prop: 'department', filter: ['selection'] },
];
grid.additionalData = { stretch: 'all' };
grid.plugins = [AdvanceFilterPlugin, ColumnStretchPlugin];
grid.filter = {
selection: {
cascadeOptions: {
enabled: true,
},
},
};
grid.theme = currentTheme().isDark() ? 'darkCompact' : 'compact';
grid.hideAttribution = true;
document.querySelector(parentSelector)?.appendChild(grid);
grid.source = rows;
return () => grid.remove();
}
grid.filter = {
selection: {
cascadeOptions: {
enabled: true,
},
},
};

If selection.getItems is provided, that custom source is used as-is. Cascade options are only applied to the built-in source loader.