Skip to content

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 },
];
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 },
];
OperatorStable IDMeaning
At leastRATING_PROGRESS_GTEValue is greater than or equal to the threshold
ExactlyRATING_PROGRESS_EQValue equals the threshold
At mostRATING_PROGRESS_LTEValue 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.

import {
RATING_PROGRESS_GTE,
defineAdvancedFilterConfig,
} from '@revolist/revogrid-pro';
grid.filter = defineAdvancedFilterConfig({
multiFilterItems: {
rating: [
{
id: 1,
type: RATING_PROGRESS_GTE,
value: 4,
relation: 'and',
},
],
},
});

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.

  • Using FILTER_RATING_PROGRESS_THRESHOLD as the condition operator; saved conditions use one of the three RATING_PROGRESS_* operator IDs.
  • Supplying a string threshold such as '80'; restore a finite number.
  • Using formatValue to convert a 0…1 source into a percentage. Use cellParser for conversion, then configure the visual domain.
  • Choosing RATING_PROGRESS_EQ with fractional data while using a step that cannot select those fractions.
  • Omitting the configured registration when replacing the complete grid.filter object later.