Skip to content

Fill Handle

Enterprise

The fill handle is the spreadsheet gesture everyone knows: select a cell or range, grab the little square at its corner, drag across neighbouring cells, and the selection’s values copy into them. fillHandle() brings it to ZenGrid — attach it to a selectionType: 'range' grid and dragging the corner handle fills the swept cells from the source range.

import { fillHandle } from '@zengrid/enterprise/grid';
const handle = fillHandle({ onFill: (range) => console.log('filled', range) });
const grid = new Zengrid(mount, { selectionType: 'range', columns });
grid.setData(rows);
handle.attach(grid);

Like a spreadsheet, the fill is constrained to one axis — whichever direction you drag further — so you fill straight down a column or across a row without smearing diagonally. The source pattern tiles: drag a two-row block down and it repeats every two rows.

The source range’s values repeat across the target, wrapping in both directions:

  • Drag one cell down five rows → that value is copied into all five.
  • Drag a Trial / Active two-cell block down → the target alternates Trial, Active, Trial, Active, ….
  • Drag left or up past the source → the pattern tiles backwards too.
Option Effect
onFill(range) Called after a fill commits, with the filled rectangle (source coordinates).
handleClass Extra CSS class on the handle element, to restyle the grip.

Each demo seeds a source selection, then attaches the fill handle. Grab the corner square and drag down (or across) — the swept cells take the source values.

The Role cell of row 0 is seeded. Drag the corner square straight down — the role copies into every swept cell.