# DataGridRowDragEvent (@salmonui/data-grid)

> The DataGridRowDragEvent interface of @salmonui/data-grid: Row drag events (onRowDragStart, onRowDrag, onBeforeRowDrop, onRowDrop).

Canonical: https://salmonui.dev/docs/reference/data-grid/DataGridRowDragEvent

```ts
import type { DataGridRowDragEvent } from '@salmonui/data-grid';
```

Entry index: https://salmonui.dev/docs/reference/data-grid (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/data-grid.md).

## Reference

Kind: interface

```ts
interface DataGridRowDragEvent<Row> extends DataGridEvent {
    readonly rowIds: readonly RowId[];
    rows(): readonly Row[];
    readonly fromIndex: number;
    readonly toIndex: number;
    readonly targetRowId: RowId | null;
    readonly position: 'before' | 'after' | 'into' | null;
    readonly parentId?: RowId | null;
    readonly valid: boolean;
    readonly reason: string | null;
    readonly targetGridId: string | null;
    readonly target: Element | null;
}
```

Row drag events (`onRowDragStart`, `onRowDrag`, `onBeforeRowDrop`, `onRowDrop`).

Members (15):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `rowIds` | `readonly rowIds: readonly RowId[];` |  |  |
| `rows` | `rows(): readonly Row[];` |  | The dragged rows (raw references). |
| `fromIndex` | `readonly fromIndex: number;` |  | Data row index of the first dragged row (-1 for rows from another grid). |
| `toIndex` | `readonly toIndex: number;` |  | Data row index the first row occupies after the drop; -1 without a valid target. |
| `targetRowId` | `readonly targetRowId: RowId \| null;` |  | Target row and side; null outside the grid rows. |
| `position` | `readonly position: 'before' \| 'after' \| 'into' \| null;` |  |  |
| `parentId` | `readonly parentId?: RowId \| null;` | optional | Tree mode: the parent the rows join (`into`: the target row; null: the roots); undefined outside tree mode. |
| `valid` | `readonly valid: boolean;` |  |  |
| `reason` | `readonly reason: string \| null;` |  | Why the target is invalid (`self`, `sorted`, `groupChange`, ...), or null. |
| `targetGridId` | `readonly targetGridId: string \| null;` |  | The grid the rows drop into: this grid's id, another grid's id, or null (custom target or nowhere). |
| `target` | `readonly target: Element \| null;` |  | Element under the pointer (pointer drags); null for keyboard and API moves. |
| `type` | `type: string;` | inherited | `'sortChange'`, `'beforeSortChange'`, ... |
| `source` | `source: DataGridEventSource;` | inherited |  |
| `defaultPrevented` | `defaultPrevented: boolean;` | inherited | True after `preventDefault()` (before-events and click events). |
| `preventDefault` | `preventDefault: () => void;` | inherited | Before-events and click events: cancels the action (or the built-in behavior). |
