Skip to content

Slider Editor

The editorSlider is a custom cell editor for RevoGrid that provides a slider input to edit numeric values within a specified range directly within the grid cells.

Source code
import { defineCustomElements } from '@revolist/revogrid/loader';
import { editorSlider } from '@revolist/revogrid-pro';
import { currentTheme } from '../composables/useRandomData';
defineCustomElements();
export function load(parentSelector: string) {
const grid = document.createElement('revo-grid');
grid.range = true;
grid.source = [
{ name: 'John Doe', rating: 85, progress: 45 },
{ name: 'Jane Smith', rating: 92, progress: 78 },
{ name: 'Bob Johnson', rating: 78, progress: 60 },
{ name: 'Alice Brown', rating: 95, progress: 89 },
{ name: 'Charlie Wilson', rating: 88, progress: 72 },
];
grid.columns = [
{ prop: 'name', size: 150 },
{
name: 'Rating (0-100)',
prop: 'rating',
cellTemplate: editorSlider,
min: 0,
max: 100,
step: 1,
},
{
name: 'Progress (%)',
prop: 'progress',
cellTemplate: editorSlider,
min: 0,
max: 100,
step: 5,
},
];
const { isDark } = currentTheme();
grid.theme = isDark() ? 'darkCompact' : 'compact';
grid.hideAttribution = true;
document.querySelector(parentSelector)?.appendChild(grid);
}

Features:

  • Renders a slider input element for cells, allowing users to select numeric values by dragging a slider handle
  • Supports customizable minimum and maximum values through column properties
  • Automatically dispatches a celledit event upon change, updating the grid’s data model with the new value
  • Ensures seamless integration with RevoGrid by providing row and column details in the event payload