Skip to content

Filter Selection

The Advanced Filtering Plugin for RevoGrid extends the grid’s capabilities by introducing powerful filtering options, making data management more efficient and flexible. This plugin includes new filter types, such as slider and selection, which provide intuitive ways for users to interact with and refine data views.

Source code
src/components/filter-selection/FilterAdvanced.ts
import { defineCustomElements } from '@revolist/revogrid/loader';
import { AdvanceFilterPlugin, ColumnStretchPlugin } from '@revolist/revogrid-pro';
defineCustomElements();
import { currentTheme, useRandomData } from '../composables/useRandomData';
const { createRandomData } = useRandomData();
const { isDark } = currentTheme();
export function load(parentSelector: string) {
const grid = document.createElement('revo-grid');
grid.source = createRandomData(100);
grid.columns = [
{
name: 'πŸ†” ID',
prop: 'id',
},
{
name: '🍎 Fruit',
prop: 'name',
filter: ['string', 'selection']
},
{
name: 'πŸ’° Price',
prop: 'price',
},
];
// Define plugin
grid.plugins = [AdvanceFilterPlugin, ColumnStretchPlugin];
grid.additionalData = {
stretch: 'all'
};
grid.filter = {};
grid.theme = isDark() ? 'darkCompact' : 'compact';
grid.hideAttribution = true;
document.querySelector(parentSelector)?.appendChild(grid);
}

Key Features

  • Custom Filter Types: Enables the use of slider and selection filters, allowing users to quickly narrow down data based on specific criteria.
  • Flexible and Extensible: This plugin demonstrates the potential for creating custom plugins, encouraging developers to expand the grid’s functionality further.
  • Automatic Theme Support: The plugin adapts to light or dark themes based on user settings.

Filter Selection Options

  • sortDirection: The default sort direction, can be β€˜asc’ or β€˜desc’ or β€˜none’
  • selectionTitle: The title of the selection filter
  • sliderTitle: The title of the slider filter
grid.filter = {
localization: {
captions: {
selectionTitle: 'Selection',
sliderTitle: 'Slider',
},
},
selection: {
sortDirection: 'asc', // default sort direction, can be 'asc' or 'desc' or 'none'
},
};

Usage Example

import { AdvanceFilterPlugin } from '@revolist/revogrid-pro';
// ...
grid.columns = [
{
// ...
filter: ['string', 'selection']
}
];
grid.plugins = [AdvanceFilterPlugin];
grid.filter = {
localization: {
captions: {
selectionTitle: 'Selection',
},
},
selection: {
sortDirection: 'asc', // default sort direction, can be 'asc' or 'desc' or 'none'
},
};

Customization and Extensibility

This plugin highlights the extensibility of RevoGrid’s plugin system, showcasing how developers can build and integrate advanced features tailored to specific needs. The flexibility of RevoGrid plugins enables comprehensive data manipulation and display control, making it an ideal choice for complex data-driven applications. For a deeper dive into plugin development, refer to the RevoGrid Plugin Documentation.