LyteNyte Grid logo for light mode. Links back to the documentation home page.
Rows

Row Dragging

Drag and drop rows within the same LyteNyte Grid, across multiple grids, or into external drop zones.

Single Row Dragging

LyteNyte Grid implements row dragging through hooks. Use the grid.api.useRowDrag hook to enable row dragging. This hook returns drag props that you attach to a drag handle component. It requires a getDragData callback, which must return drag data in the following shape:

export interface DragData {
readonly siteLocalData?: Record<string, any>;
readonly dataTransfer?: Record<string, string>;
}

Drop zones must declare which drag data keys they accept. For example, the Row component acts as a drop zone. Set its accepted property to define which drag data it can receive. The demo below shows a basic single-row drag setup. Focus on the marker column's cellRenderer and the accepted prop on Grid.Row.

Single Row Dragging

Dragging Multiple Rows

Combine row dragging with row selection to support dragging multiple rows. Instead of returning data for a single row, use getDragData to include all selected rows from the selection state.

Multiple Row Dragging

Dragging Between Grids

To enable dragging between grids, use a shared accepted value. For example, setting accepted={["row"]} on both grids allows drag data containing a row key to be dropped onto rows in either grid.

Grid-to-Grid Dragging

External Drop Zones

Use the DropWrap component to create external drop zones. DropWrap renders a div that handles all required drag events and can accept any drag data produced by the grid.

External Drop Zones

Drag a row here

Next Steps