Rating or Progress Threshold Filter
Use this filter for star ratings, completion percentages, health scores, and other bounded numeric values. Users choose greater-than-or-equal, equal, or less-than-or-equal and then set one threshold.
Source code
TypeScriptts
grid.plugins = [AdvanceFilterPlugin];
grid.columns = [
{ prop: 'review', name: 'Review' },
{
prop: 'rating',
name: 'Rating',
filter: ['number', FILTER_RATING_PROGRESS_THRESHOLD],
},
];
grid.filter = true;
return [
{ review: 'Needs work', rating: 1 },
{ review: 'Fair', rating: 2 },
{ review: 'Good', rating: 3 },
{ review: 'Great', rating: 4 },
{ review: 'Excellent', rating: 5 },
];Quick start
Section titled “Quick start”import { defineCustomElements } from '@revolist/revogrid/loader';import { AdvanceFilterPlugin, FILTER_RATING_PROGRESS_THRESHOLD,} from '@revolist/revogrid-pro';import '@revolist/revogrid-pro/dist/revogrid-pro.css';
defineCustomElements();
const grid = document.createElement('revo-grid');grid.plugins = [AdvanceFilterPlugin];grid.columns = [ { prop: 'task', name: 'Task' }, { prop: 'rating', name: 'Rating', filter: ['number', FILTER_RATING_PROGRESS_THRESHOLD], },];grid.filter = true;document.querySelector('#app')!.append(grid);grid.source = [ { task: 'Design', rating: 4.5 }, { task: 'Build', rating: 3 }, { task: 'Review', rating: 5 },];Operators and state
Section titled “Operators and state”| Operator | Stable ID | Meaning |
|---|---|---|
| At least | RATING_PROGRESS_GTE | Value is greater than or equal to the threshold |
| Exactly | RATING_PROGRESS_EQ | Value equals the threshold |
| At most | RATING_PROGRESS_LTE | Value is less than or equal to the threshold |
The condition value is one finite number. The type ID is FILTER_RATING_PROGRESS_THRESHOLD ('ratingProgressThreshold'). Values are clamped to 0…max and aligned to the configured step.
Restore a threshold programmatically
Section titled “Restore a threshold programmatically”import { RATING_PROGRESS_GTE, defineAdvancedFilterConfig,} from '@revolist/revogrid-pro';
grid.filter = defineAdvancedFilterConfig({ multiFilterItems: { rating: [ { id: 1, type: RATING_PROGRESS_GTE, value: 4, relation: 'and', }, ], },});Configuration
Section titled “Configuration”The default presentation is stars with max: 5 and step: 1. Percent and score presentations default to a maximum of 100.
import { createRatingProgressThresholdStructuredFilterType, defineAdvancedFilterConfig,} from '@revolist/revogrid-pro';
const progress = createRatingProgressThresholdStructuredFilterType({ unit: 'percent', // 'stars', 'percent', or 'score' max: 100, step: 5, formatValue: (value) => `${value}%`,});
grid.filter = defineAdvancedFilterConfig({ structuredFilterTypes: [progress],});max and step must be positive. A step larger than the maximum is normalized to the maximum. formatValue changes the displayed value text; it does not transform source values.
Common mistakes
Section titled “Common mistakes”- Using
FILTER_RATING_PROGRESS_THRESHOLDas the condition operator; saved conditions use one of the threeRATING_PROGRESS_*operator IDs. - Supplying a string threshold such as
'80'; restore a finite number. - Using
formatValueto convert a0…1source into a percentage. UsecellParserfor conversion, then configure the visual domain. - Choosing
RATING_PROGRESS_EQwith fractional data while using a step that cannot select those fractions. - Omitting the configured registration when replacing the complete
grid.filterobject later.