Skip to content

defaultPasteHandler

Since v0.4.2

Default paste handler that applies pasted data to the grid.

This is the built-in handler used when no custom pasteHandler is configured.

Edits are routed through grid.updateRows(…, 'paste') so paste participates in the full edit pipeline — dirty tracking, cancelable validation, undo/redo history, and abortion — exactly like an interactive edit, and so a cell-commit listener can tell a paste apart via detail.source === 'paste'. Rows without a resolvable ID (no getRowId) fall back to a direct in-place write, which still updates values but does not track them.

Behavior:

  • Single cell selection: paste expands freely, adds new rows if needed
  • Range/row selection: paste is clipped to fit within selection bounds
  • Fill-selection: when detail.fillSelection is set, the source is tiled (repeated via modulo indexing) to fill the whole selection bounds
  • Non-editable cells: values are skipped (column alignment preserved). Editability is resolved by the editing plugin via the getCellEditableResolver query — including row-conditional editable. Without the editing plugin, no cell is editable and paste is a no-op.
  • Per-column onPaste: after the editability check, a column’s BaseColumnConfig.onPaste may reject the cell (skipped, alignment preserved) or transform the pasted value. Rejected cells are reported once via the paste-rejected event (PasteRejectedDetail).
function defaultPasteHandler(detail: PasteDetail, grid: GridElement): void
NameTypeDescription
detailPasteDetailThe parsed paste data from clipboard
gridGridElementThe grid element to update
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://toolboxjs.com/llms-full.txt