# ViewportDatasource

Fields, allowed values, and APIs that use ViewportDatasource.

Canonical: https://grid.syidax.com/docs/types/ViewportDatasource/

<a id="definition"></a>

## Type definition

A question mark (?) marks an optional field; readonly marks a value you should not change directly. A union (|) accepts one of the listed forms. Functions are callbacks that Grid invokes at the relevant point.

```typescript
export interface ViewportDatasource<TRow> {
  init(callbacks: {
    setRowCount(count: number): void;
    setRowData(startIndex: number, rows: TRow[]): void;
  }): void;
  setViewportRange(
    firstRow: number,
    lastRow: number,
    request?: ViewportRequestContext,
  ): void;
  destroy?(): void;
}
```

<a id="used-by"></a>

## APIs using this type

- [viewportDatasource](https://grid.syidax.com/docs/options/viewportDatasource.md) — Viewport model supplying data for visible row ranges. Implement initialization, range changes, and cleanup.

<a id="related"></a>

## Related types

- [ViewportRequestContext](https://grid.syidax.com/docs/types/ViewportRequestContext.md)
