# DataGridBeforeCopyEvent (@salmonui/data-grid)

> The DataGridBeforeCopyEvent interface of @salmonui/data-grid: onBeforeCopy: preventDefault() cancels, assigning data replaces the text.

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

```ts
import type { DataGridBeforeCopyEvent } 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 DataGridBeforeCopyEvent extends DataGridEvent {
    data: string;
    readonly includeHeaders: boolean;
    readonly copied: 'range' | 'rows' | 'cell';
    readonly cells: number;
    readonly rowIds: readonly RowId[];
    readonly fields: readonly string[];
}
```

`onBeforeCopy`: `preventDefault()` cancels, assigning `data` replaces the text.

Members (10):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `data` | `data: string;` |  | The TSV text about to be written to the clipboard. Assign to replace it. |
| `includeHeaders` | `readonly includeHeaders: boolean;` |  |  |
| `copied` | `readonly copied: 'range' \| 'rows' \| 'cell';` |  | What was copied: the cell range, the selected rows, or the focused cell. |
| `cells` | `readonly cells: number;` |  | Copied data cells (headers excluded). |
| `rowIds` | `readonly rowIds: readonly RowId[];` |  |  |
| `fields` | `readonly fields: readonly string[];` |  |  |
| `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). |
