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.

Source code
import { defineCustomElements } from '@revolist/revogrid/loader';
import {
RowEditPlugin,
RowOddPlugin,
editorRowActionColumn,
} from '@revolist/revogrid-pro';
import { currentTheme } from '../composables/useRandomData';
defineCustomElements();
const source = [
{ name: 'John Doe', age: 25, dateOfBirth: '1998-01-15' },
{ name: 'Jane Smith', age: 30, dateOfBirth: '1993-03-22' },
{ name: 'Jim Beam', age: 35, dateOfBirth: '1988-06-09' },
{ name: 'Anna Bell', age: 28, dateOfBirth: '1995-11-18' },
{ name: 'Chris Green', age: 41, dateOfBirth: '1982-04-03' },
{ name: 'Maria Stone', age: 33, dateOfBirth: '1990-08-27' },
{ name: 'Peter Brown', age: 46, dateOfBirth: '1977-12-12' },
{ name: 'Sofia Clark', age: 29, dateOfBirth: '1994-02-05' },
{ name: 'Leo Turner', age: 38, dateOfBirth: '1985-09-21' },
{ name: 'Nina White', age: 31, dateOfBirth: '1992-07-14' },
{ name: 'Mark Young', age: 44, dateOfBirth: '1979-10-30' },
{ name: 'Olivia Lane', age: 27, dateOfBirth: '1996-05-19' },
];
export function load(parentSelector: string) {
const grid = document.createElement('revo-grid');
grid.range = true;
grid.columns = [
{ prop: 'name' },
{ prop: 'age' },
{ prop: 'dateOfBirth' },
{ prop: 'edit', ...editorRowActionColumn },
];
grid.plugins = [RowEditPlugin, RowOddPlugin];
const { isDark } = currentTheme();
grid.theme = isDark() ? 'darkMaterial' : 'material';
grid.hideAttribution = true;
document.querySelector(parentSelector)?.appendChild(grid);
grid.source = source;
return () => grid.remove();
}
  • 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.