Skip to content

Row Editor

The RowEditPlugin is a custom plugin for RevoGrid that provides row-level editing capabilities, allowing users to edit entire rows inline with dedicated action buttons for saving or canceling changes.

  • Features:
  • Row Editing Mode: Enables editing of entire rows by rendering editors for all cells in the selected row.
  • Inline Editors: Supports inline editing of multiple cells in a row simultaneously.
  • Action Buttons: Provides intuitive buttons for Save and Cancel actions:
    • Save: Dispatches CELL_EDIT_SAVE_EVENT to persist changes.
    • Cancel: Dispatches CELL_EDIT_CANCEL_EVENT to discard changes.
  • Event Handling: Listens for key events to manage row editing:
    • CELL_EDIT_EVENT: Initiates row editing mode.
    • CELL_EDIT_SAVE_EVENT: Saves edited data and updates the grid model.
    • CELL_EDIT_CANCEL_EVENT: Cancels editing and restores original data.
    • BEFORE_CELL_RENDER_EVENT: Ensures cells in the editing row render with editors.
Source code
import { defineCustomElements } from '@revolist/revogrid/loader';
import { RowEditPlugin, editorRowActionColumn } 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', age: 25, dateOfBirth: '1998-01-15' },
{ name: 'Jane Smith', age: 30, dateOfBirth: '1993-03-22' },
];
grid.columns = [
{ prop: 'name' },
{ prop: 'age' },
{ prop: 'dateOfBirth' },
{ prop: 'edit', ...editorRowActionColumn },
];
grid.plugins = [RowEditPlugin];
const { isDark } = currentTheme();
grid.theme = isDark() ? 'darkCompact' : 'compact';
grid.hideAttribution = true;
document.querySelector(parentSelector)?.appendChild(grid);
}