Ga naar hoofdinhoud

CnDashboardGrid

Low-level drag-and-drop grid layout engine powered by GridStack. Manages widget placement, drag, and resize interactions and emits layout changes for persistence. Does not handle widget rendering — the parent provides content via the #widget scoped slot.

Used internally by CnDashboardPage. Only use this directly if you need fine-grained control over the grid without the full dashboard page shell.

Requires: gridstack (bundled dependency)

Try it

Loading CnDashboardGrid playground…

Usage

<CnDashboardGrid
:layout="placements"
:editable="isEditing"
:columns="12"
:cell-height="80"
@layout-change="onLayoutChange">
<template #widget="{ item }">
<MyWidget :config="item" />
</template>
</CnDashboardGrid>
// Layout item shape
const placements = [
{ id: 1, gridX: 0, gridY: 0, gridWidth: 6, gridHeight: 3 },
{ id: 2, gridX: 6, gridY: 0, gridWidth: 6, gridHeight: 3 },
]

function onLayoutChange(updated) {
// updated is the full layout array with new x/y/w/h values
saveLayout(updated)
}

Props

PropTypeRequiredDefaultDescription
layoutArrayArray of layout items: { id, gridX, gridY, gridWidth, gridHeight, ...extra }
editableBooleanfalseEnables drag and resize interactions
columnsNumber12Number of grid columns
cellHeightNumber80Cell height in pixels
marginNumber12Gap between grid items in pixels
minWidthNumber2Minimum widget width in grid units
minHeightNumber2Minimum widget height in grid units

Events

EventPayloadDescription
layout-changelayout[]Emitted when any item is dragged or resized; payload is the full updated layout array

Slots

SlotScopeDescription
widget{ item }Content to render inside each grid cell; item is the layout object

Reference (auto-generated)

The tables below are generated from the SFC source via vue-docgen-cli. They reflect what's actually in CnDashboardGrid.vue and update automatically whenever the component changes.

Props

NameTypeRequiredDefaultDescription
layoutarrayArray of layout items: { id, gridX, gridY, gridWidth, gridHeight, ...extra }
editablebooleanfalseWhether drag and resize are enabled
columnsnumber12Number of grid columns
cellHeightnumber80Cell height in pixels
marginnumber12Grid margin in pixels
minWidthnumber2Minimum widget width in grid units
minHeightnumber2Minimum widget height in grid units

Events

NamePayloadDescription
layout-change

Slots

NameBindingsDescription
widgetitem