Skip to content

Querying, copying and selecting merged cells ​

How to ask for cells merged with the column keys merge (vertical) and mergeCols (horizontal), and how copy and selection treat them (1.4.0). Merging itself is described in Column definitions. Without the options below nothing changes.

Ask for a merged span ​

ts
api.getMergeSpan(2, 'dept'); // { rows: 3, cols: 1, start: { rowKey: 1, columnId: 'dept' } } or null
api.isMerged(2, 'dept'); // true | false
MethodReturns
getMergeSpan(rowKey, columnId)The merged span { rows, cols, start } the cell belongs to, or null
isMerged(rowKey, columnId)Whether the cell belongs to a merged span
RuleContent
SizeA vertical merge is { rows: n, cols: 1 }, a horizontal merge (mergeCols) is { rows: 1, cols: m }
startEvery cell of the span returns the same first cell (first row, or the start column for horizontal)
nullCells that are not merged, one-cell spans, cells of hidden columns and rows that are filtered out
ScopeComputed over all visible rows, not only the drawn ones, so a span that continues outside the virtual window is right
RecomputeA sort, a filter or an expansion recalculates on the visible lines; pinned rows and the body never merge together
ErrorsAn unknown column id is an invalid-option

Copy and paste text (mergeCopy) ​

mergeCopy on a column sets the text used when a vertically merged span is copied.

ValueCopied text
'all'Default. Each cell's own text
'first'Text only on the first row of the span, empty text on the covered rows
'repeat'The first row's text repeated on every row (differs when rows with the same shown text hold different values)

When text copied with 'first' is pasted back, an empty text on a covered row does not clear the value (only the first row is written). A cut clears every row.

Selecting merged cells (selection.mergeSelect) ​

ts
selection: { mode: 'multiple', mergeSelect: 'span' }
ValueBehavior
'cell'Default (unchanged). Selects only the pressed cell; pressing the covered area of a merged cell is the span's first cell
'span'Choosing any cell of a span, or dragging over part of it, grows the selection to the whole span; vertical and horizontal merges; row selection is unchanged

hooks.canSelect is asked for the two end cells of the grown range, and the selection stays as it was when it refuses.

One check cell per merged span (selection.mergeCheck) ​

ts
selection: { mode: 'multiple', checkbox: true, mergeCheck: true }

In a vertical span of the first visible merged column, the check cell is drawn only on the first row of the span and shows the state of the whole span (all, some or none). Pressing it selects every row of the span, or clears them all when everything is selected. Rows locked by isRowSelectable and canDeselect: false are respected. It works only with mode: 'multiple' and checkbox.

See also ​