Documentation

@kanunilabs/datagrid-react


@kanunilabs/datagrid-react / DataGridCardViewOptions

Interface: DataGridCardViewOptions<TRow>

cardView options of the React grids (P-9): the shared ones (CardViewOptions: breakpoint, columns) plus the card as a tap target.

Extends

  • CardViewOptions

Type Parameters

TRow

TRow = GridRowData

Properties

breakpoint?

optional breakpoint?: number

Show cards while the grid is narrower than this, in pixels. Default 600 — a phone held upright, and a narrow side panel. Infinity shows cards at every width.

Inherited from

CardViewOptions.breakpoint


columns?

optional columns?: string[]

Columns on a card, in order; the first is the card's title. Default: the visible columns in their current order.

Inherited from

CardViewOptions.columns


edit?

optional edit?: "popup"

'popup': pressing a card on an editing grid opens its row in the edit dialog (the editing.mode: 'popup' form), whatever editing.mode is. Save follows the mode: batch keeps the values pending for the batch Save, cell writes them into the row and sends the row once (also under commitOn: 'row' — closing the form is leaving the row), a row mode saves the row. Cancel puts the row back as it was when the dialog opened. The dialog stays open when the grid widens back into a table.


height?

optional height?: number

Height of every card in pixels. Default: the default card's height for its field count (title 22 px, 20 px a line, 21 px of padding; at least 44 — a touch target).


onCardPress?

optional onCardPress?: (rowKey, node, event) => void

A card was pressed — tapped, or clicked with a mouse. A touch that moves more than 10 px (a scroll, a swipe) is not a press. Called after the grid has made the row the focused one (so onFocusedRowChanged has already fired for it) and before edit: 'popup' opens it. event.preventDefault() keeps the popup closed.

Parameters

rowKey

RowKey

node

DataRowNode<TRow>

event

MouseEvent<HTMLElement>

Returns

void


renderCard?

optional renderCard?: (ctx) => ReactNode

Draw a card's content yourself. The grid keeps the card's box — its height, the press, selection, the rowStatus marker and rowClassName on the row element — and puts what this returns inside it. Cards are virtualised like rows, so every card is height pixels tall: give height when your card is not the default card's height.

Parameters

ctx

CardRenderContext<TRow>

Returns

ReactNode