Skip to content
Grid LayoutAPI Reference

DashboardGridHandle

comins-grid-layout@0.3.0React

Nine ref methods to inspect and refresh the mounted GridStack engine.

Pass useRef<DashboardGridHandle>(null) to DashboardGrid.ref. The engine can still be initializing asynchronously after the React ref exists, so handle null query results too. Do not reuse the ref after unmount.

DashboardGridHandle inspects, measures, and compacts the engine. DashboardGridCommands changes React state. Connect onLayoutCommit={grid.commands.applyLayoutSnapshot} to accept engine geometry.

getGridStack(): GridStack | null;

Returns the active GridStack instance, or null before engine initialization. React owns widget DOM and teardown; do not change component membership through raw addWidget, removeWidget, load, or destroy. Use Comins state commands.

getColumnCount(): number | null;

Returns the engine’s active column count, which can differ from the base columns under responsive configuration. Returns null before initialization.

getRowCount(): number | null;

Returns the engine’s grid row count, not widget count or pixel height. Returns null before initialization.

getFloat(): boolean | null;

Returns the current engine float setting. false is a valid setting, distinct from the uninitialized null result.

isAreaEmpty(layout: Omit<DashboardWidgetLayout, "id">): boolean | null;

Accepts a layout without an ID and reports whether its (x, y, w, h) area is empty. Does not insert or reserve a widget. Returns null before initialization.

willItFit(layout: Omit<DashboardWidgetLayout, "id">): boolean | null;

Checks whether the layout without an ID can fit under engine constraints such as maxRow. This is neither insertion confirmation nor the same query as area emptiness. Returns null before initialization.

refresh(): void;

Refreshes sizing and drag handles, then measures again in the next animation frame. With sizeToContent enabled it also resizes content. Returns void, not a completion promise. Does nothing before initialization.

compact(layout?: CompactOptions, doSort?: boolean): DashboardLayoutSnapshot | null;

Defaults to layout="compact" and doSort=true. "compact" may reorder to fill gaps; "list" preserves left-to-right order. Sorting uses engine coordinates. Mutates engine geometry and passes through commit, returning a geometry snapshot. Returns null before initialization, rather than the fluent GridStack instance.

commitLayout(): DashboardLayoutSnapshot | null;

Reads the current engine geometry snapshot and, when needed, notifies onWidgetLayoutChange and onLayoutCommit. Identical commits do not repeat callbacks. In non-responsive mode, a mismatch between engine and controlled column counts returns the snapshot without notifying. Returns null before initialization. Does not perform network persistence.

GridStack and CompactOptions come from the installed gridstack@13.2.0. This page describes the nine Comins wrapper methods. For other engine capabilities, see advanced GridStack access and that version’s declarations.

The npm declarations below were compared with a fixed source snapshot. The snapshot is the commit recorded in the public artifact provenance.