bo-grid v3.1.0

Large data

.md

Wide grids

Render only the columns in view for grids with dozens or hundreds of columns, and highlight the column under the pointer.

Rows are always virtualized: only the rows in view are drawn. For grids with many columns (a price history by day, a risk matrix, a wide export), virtualizeColumns does the same across: only the columns in the horizontal scroll window, plus a small buffer, are drawn, so a grid of a hundred columns costs about as much as one of ten.

41 columns, of which only the visible ones render. Scroll sideways; the Symbol column stays pinned, and the column under the pointer lights up.

wide-grids.svelte GitHub ↗

Turning it on

<Grid {rows} {columns} height={520} virtualizeColumns />
  • Columns get pixel widths and the grid scrolls horizontally; flex columns grow to fill any width left over.
  • Pinned columns always render, so a label column stays put on the left (or right). See Pinned columns.
  • colSpan is ignored while columns are virtualized: every cell draws in its own column.

Without virtualizeColumns, columns fit the grid’s width and every column renders, which is the better choice up to a few dozen columns.

Following a column

On a wide board, columnHover highlights the column under the pointer, body and header, so a value is easy to follow down its column. It draws one overlay for the whole column rather than restyling each cell, and covers pinned columns too. Its colour is the theme token colHover.

<Grid {rows} {columns} height={520} virtualizeColumns columnHover />

Sixty columns

A wide board with a pinned label column:

WideGrid.svelte Open GitHub ↗

Reference

Grid props from the types
virtualizeColumns boolean Default false

Render only the columns within the horizontal scroll window (+ overscan) for very wide grids (100+ columns). Forces fixed-width horizontal scroll; pinned columns always render. Off, the columns fit the grid's width.

columnHover boolean Default false

Highlight the column under the pointer (body and header) — handy on a wide board. One overlay for the whole column, not a class per cell.

Column options from the types
pinned boolean | 'left' | 'right' Default false

Pin this column so it stays visible during horizontal scroll. true / 'left' pins to the left edge, 'right' to the right.

width number Default 96

Width in px. A flex column starts from it where columns have fixed widths (pinned columns, virtualizeColumns), and fitColumns scales columns in proportion to it.

colSpan (row: GridRow) => number

How many columns this cell covers for a given row (1 when unset). Covered cells are not drawn. Clamped at a pinned/scrolling boundary and the last column; the leftmost claim wins. Ignored under virtualizeColumns.

Example
{ type: 'text', key: 'sym', header: 'Symbol', colSpan: (row) => (row.kind === 'note' ? 4 : 1) }