# DataGridSaveEvent (@salmonui/data-grid)

> The DataGridSaveEvent interface of @salmonui/data-grid: onBeforeSave (before the write is sent; cancellable) / onSave (after the write settled). Lists are computed on first read.

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

```ts
import type { DataGridSaveEvent } 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 DataGridSaveEvent<Row> extends DataGridEvent {
    readonly mode: EditMode;
    readonly added: readonly RowId[];
    readonly changed: readonly {
        readonly rowId: RowId;
        readonly fields: readonly string[];
    }[];
    readonly deleted: readonly RowId[];
    rows(): EditBatchChanges<Row>;
    readonly status: DataGridSaveStatus;
    readonly result: WriteResult<Row> | null;
    readonly error: Error | null;
    readonly failedRowIds: readonly RowId[];
}
```

`onBeforeSave` (before the write is sent; cancellable) / `onSave` (after
the write settled). Lists are computed on first read.

Members (13):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `mode` | `readonly mode: EditMode;` |  |  |
| `added` | `readonly added: readonly RowId[];` |  |  |
| `changed` | `readonly changed: readonly {     readonly rowId: RowId;     readonly fields: readonly string[]; }[];` |  |  |
| `deleted` | `readonly deleted: readonly RowId[];` |  |  |
| `rows` | `rows(): EditBatchChanges<Row>;` |  | The rows with drafts applied (before-event); the rows written, with the source's echo where it sent one (after-event). |
| `status` | `readonly status: DataGridSaveStatus;` |  | `pending` before the write; `applied`, `partial` (some rows failed), `rejected`, or `error` (the write threw) after. |
| `result` | `readonly result: WriteResult<Row> \| null;` |  | The data source's write result (after-event), else null. |
| `error` | `readonly error: Error \| null;` |  | The error a failed write threw (status `error`), else null. |
| `failedRowIds` | `readonly failedRowIds: readonly RowId[];` |  | Rows the write did not apply (row or cell errors, conflicts, rejection); they keep their drafts. |
| `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). |
