Skip to content

UpdateSource

Since v1.0.0

Indicates the origin of a data change. Used to prevent infinite loops in cascade update handlers.

  • 'user': Direct user interaction via EditingPlugin (typing, selecting)
  • 'cascade': Triggered by updateRow() in an event handler
  • 'api': External programmatic update via grid.updateRow()
  • 'sync': Declarative data replacement from the host (e.g. a framework adapter syncing its rows prop in place). Applied to the grid data but treated as authoritative external data, NOT a user edit: data plugins (e.g. editing) MUST NOT mark the row dirty or record undo/redo history.
  • 'history': Re-application of a value by the undo/redo plugin. Data plugins (e.g. editing) apply the value but MUST NOT record a fresh history entry or mark the row changed — the undo stack owns this change.
type UpdateSource = keyof UpdateSourceMap
grid.on('cell-change', (detail) => {
const { source, field, newValue } = detail;
// Only cascade updates for user edits
if (source === 'user' && field === 'price') {
// Update calculated field (marked as 'cascade')
grid.updateRow(detail.rowId, {
total: newValue * detail.row.quantity,
});
}
// Ignore cascade updates to prevent infinite loops
if (source === 'cascade') return;
});
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://toolboxjs.com/llms-full.txt