# DataGridViewApi (@salmonui/data-grid)

> The DataGridViewApi interface of @salmonui/data-grid.

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

```ts
import type { DataGridViewApi } 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 DataGridViewApi {
    getViewport(): DataGridViewport;
    subscribeViewport(listener: () => void): () => void;
    getRowOffsets(): RowMetrics;
    scrollTo(options: DataGridScrollToOptions): void;
    getPageSizeForHeight(height: number): number;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `getViewport` | `getViewport(): DataGridViewport;` |  | Scroll sync extension point: the current body viewport. |
| `subscribeViewport` | `subscribeViewport(listener: () => void): () => void;` |  | Calls `listener` outside React on every body scroll and layout change; returns the unsubscribe function. |
| `getRowOffsets` | `getRowOffsets(): RowMetrics;` |  | Row height extension point: the row offsets of the visible row model (the body's own prefix sums). |
| `scrollTo` | `scrollTo(options: DataGridScrollToOptions): void;` |  | Scrolls the body to an offset. An omitted axis keeps its position; offsets are clamped to the scroll range. |
| `getPageSizeForHeight` | `getPageSizeForHeight(height: number): number;` |  | Whole data rows that fit in `height` px after the toolbar, group drop area, header rows, footer aggregate rows and pager; 0 when none fit. Rows count `rowHeight` (the estimate with measured rows, the card height in adaptive vertical mode). Before mount only the header and footer rows are subtracted. |
