Skip to content

Checkbox Editor

The editorCheckbox is a custom cell editor for RevoGrid that provides a checkbox input to edit boolean values directly within the grid cells.

  • Features:
  • Renders a checkbox input element for cells, allowing users to toggle boolean values (true/false) with a simple click.
  • 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.
Source code
import { defineCustomElements } from '@revolist/revogrid/loader';
import { editorCheckbox } 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', isProgrammer: true },
{ name: 'Jane Smith', isProgrammer: false },
];
grid.columns = [
{ prop: 'name' },
{
name: 'Editor',
prop: 'isProgrammer',
cellTemplate: editorCheckbox,
readonly: true,
},
{
name: 'Raw value',
prop: 'isProgrammer',
readonly: true,
},
];
const { isDark } = currentTheme();
grid.theme = isDark() ? 'darkCompact' : 'compact';
grid.hideAttribution = true;
document.querySelector(parentSelector)?.appendChild(grid);
}