ExamplesColumns & Pinning
Column drag & drop
Drag a header within its pin zone, or move columns programmatically with setColumnOrder.
Two paths to the same columnOrder state: drag a header (the move is scoped to the header's
pin zone), or call actions.setColumnOrder(id, targetId, position) programmatically. The demo
shows both. Name opts out with reorderable: false, and Score is pinned right, so it only
moves with the pinned zone.
Drag a header to reorder it — the move stays inside its pin zone. Name cannot be moved (reorderable: false) and Score is pinned right. The picker below the line moves the chosen column programmatically.
Move
pnpm dlx shadcn@latest add @gridcn/data-grid-column-drag-demo
What's in the demo
enableColumnReorder: header drag with a drop indicator, grid-wide defaulttruereorderable: falseon Name: the per-column opt-out that beats the grid flagpin: "right"on Score: a drag crossing pin zones is a no-op- Picker + Left/Right buttons:
setColumnOrder(selectedId, neighborId, "before" | "after")fromuseDataGridActions(), disabled at the order's edges
Behavior reference
- Reorder: the drag gesture, gating, and the layout-change payload
- Row drag & drop: the same two-path shape for rows
Related
- Column layout: the reorder persists into the layout snapshot