# @salmonui/data-grid/engine/row-pinning API reference

> 11 exported symbols of @salmonui/data-grid/engine/row-pinning: 2 functions, 1 class, 2 interfaces and 6 types.

Canonical: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning

```ts
import { … } from '@salmonui/data-grid/engine/row-pinning';
```

## Functions

### createRowPinningModule

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/createRowPinningModule

```ts
function createRowPinningModule<Row>(): RowPinningModule<Row>;
```

Creates the `rowPinning` module. Options are read from
`options.rowPinning` (`RowPinningOptions`).

### pinnedSourceIndexes

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/pinnedSourceIndexes

```ts
function pinnedSourceIndexes<Row>(model: RowModelSnapshot<Row>): Int32Array;
```

The `pinned` source indexes of a model (empty when nothing is pinned).

## Classes

### PinnedView

Kind: class

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/PinnedView

```ts
class PinnedView implements RowModelView {
    readonly kind: 'pinned';
    readonly inner: RowModelView;
    readonly count: number;
    readonly dataCount: number;
    private readonly pinned;
    private readonly sourceIds;
    private positions;
    constructor(inner: RowModelView, pinned: Int32Array, sourceIds: readonly RowId[]);
    innerIndex(index: number): number;
    outerIndex(innerIndex: number): number;
    kindAt(index: number): RowKind;
    sourceIndexAt(index: number): number;
    idAt(index: number): RowId | undefined;
    depthAt(index: number): number;
    private positionOf;
    indexOfSource(sourceIndex: number): number;
    parentOfSource(sourceIndex: number): RowId | null;
    resolve(id: RowId): ViewRowInfo | undefined;
}
```

Visible model with the pinned rows in front of a structured inner view
(grouped, detail, lazy groups, or a page of them). Pinned rows are data
rows at depth 0; every other lookup is the inner lookup shifted by the
pinned count.

Members (17):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `kind` | `readonly kind: 'pinned';` |  |  |
| `inner` | `readonly inner: RowModelView;` |  |  |
| `count` | `readonly count: number;` |  |  |
| `dataCount` | `readonly dataCount: number;` |  |  |
| `pinned` | `private readonly pinned;` |  |  |
| `sourceIds` | `private readonly sourceIds;` |  |  |
| `positions` | `private positions;` |  |  |
| `innerIndex` | `innerIndex(index: number): number;` |  | Inner index of a visible index, or -1 for a pinned row. |
| `outerIndex` | `outerIndex(innerIndex: number): number;` |  | Visible index of an inner index. |
| `kindAt` | `kindAt(index: number): RowKind;` |  |  |
| `sourceIndexAt` | `sourceIndexAt(index: number): number;` |  |  |
| `idAt` | `idAt(index: number): RowId \| undefined;` |  |  |
| `depthAt` | `depthAt(index: number): number;` |  |  |
| `positionOf` | `private positionOf;` |  |  |
| `indexOfSource` | `indexOfSource(sourceIndex: number): number;` |  |  |
| `parentOfSource` | `parentOfSource(sourceIndex: number): RowId \| null;` |  |  |
| `resolve` | `resolve(id: RowId): ViewRowInfo \| undefined;` |  |  |

## Interfaces

### RowPinningOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/RowPinningOptions

```ts
interface RowPinningOptions<Row> {
    readonly isRowPinned?: (row: Row) => boolean;
    readonly rowIds?: readonly RowId[];
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `isRowPinned` | `readonly isRowPinned?: (row: Row) => boolean;` | optional | Rows pinned by data. Evaluated once per row of a data array; a patch re-tests only the added and changed rows, so pinning follows CRUD. Must be pure. Read at engine creation. |
| `rowIds` | `readonly rowIds?: readonly RowId[];` | optional | Initially pinned row ids (besides `isRowPinned`). |

### RowPinningState

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/RowPinningState

```ts
interface RowPinningState {
    readonly pinned: readonly RowId[];
    readonly unpinned: readonly RowId[];
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `pinned` | `readonly pinned: readonly RowId[];` |  | Rows pinned explicitly (`pinRows`, `rowIds`), in pin order. |
| `unpinned` | `readonly unpinned: readonly RowId[];` |  | Rows unpinned explicitly although `isRowPinned` matches them. |

## Types

### RowPinningCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/RowPinningCommand

```ts
type RowPinningCommand = RowPinningPinCommand | RowPinningUnpinCommand | RowPinningSetCommand;
```

### RowPinningMethods

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/RowPinningMethods

```ts
type RowPinningMethods<Row> = {
    isPinned(ctx: ModuleContext<Row>, rowId: RowId): boolean;
    getPinnedRowIds(ctx: ModuleContext<Row>): readonly RowId[];
};
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `isPinned` | `isPinned(ctx: ModuleContext<Row>, rowId: RowId): boolean;` |  | True when the row is pinned (explicitly, or by `isRowPinned` and not unpinned). Filtered-out rows can be pinned. |
| `getPinnedRowIds` | `getPinnedRowIds(ctx: ModuleContext<Row>): readonly RowId[];` |  | Ids of the pinned rows the view shows, in display order. |

### RowPinningModule

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/RowPinningModule

```ts
type RowPinningModule<Row> = DataGridModule<Row, RowPinningState, RowPinningCommand, 'rowPinning', RowPinningMethods<Row>>;
```

Members (18):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `name` | `name: "rowPinning";` | inherited |  |
| `dependencies` | `dependencies?: readonly string[];` | optional, inherited | Validated at engine creation. |
| `inSnapshot` | `inSnapshot?: boolean;` | optional, inherited | When true (default) the slice lives in `snapshot.modules[name]` and every change replaces the grid snapshot. High-churn modules (focus, selection, drafts) set false and notify through row/cell/header/module channels only. |
| `commands` | `commands: readonly ("rowPinning.pin" \| "rowPinning.set" \| "rowPinning.unpin")[];` | inherited | Declared, validated, serializable. Every type must start with `${name}.`. |
| `initialState` | `initialState: (options: DataGridOptions<Row>) => RowPinningState;` | inherited |  |
| `reduce` | `reduce?: ((state: RowPinningState, command: RowPinningCommand, ctx: ModuleContext<Row>) => CommandRejection \| RowPinningState);` | optional, inherited |  |
| `extendColumns` | `extendColumns?: ((columns: readonly CompiledColumn<Row>[], ctx: ModuleContext<Row>) => readonly CompiledColumn<Row>[]);` | optional, inherited |  |
| `extendQuery` | `extendQuery?: ((query: DataQuery, state: RowPinningState) => DataQuery);` | optional, inherited |  |
| `pipeline` | `pipeline?: readonly PipelineStage<Row, RowPinningState>[];` | optional, inherited |  |
| `selectors` | `selectors?: Readonly<Record<string, (snapshot: DataGridSnapshot<Row>) => unknown>>;` | optional, inherited |  |
| `methods` | `methods?: RowPinningMethods<Row>;` | optional, inherited | Reads that need more than the snapshot (facets, pager totals). Must not change state; names may not collide with command actions. |
| `notify` | `notify?: ((previous: RowPinningState, next: RowPinningState, ctx: ModuleContext<Row>) => NotificationScope);` | optional, inherited |  |
| `hiddenColumns` | `hiddenColumns?: ((state: RowPinningState) => readonly string[]);` | optional, inherited | Leaf columns this module hides from the visible column set (grouped columns with `showGroupedColumns: false`). |
| `interceptRead` | `interceptRead?: ((query: DataQuery, state: RowPinningState, ctx: ModuleContext<Row>) => boolean);` | optional, inherited | Remote sources only: return true to serve the main read of `query` yourself (lazy grouping loads group levels instead of rows). The engine then shows no source rows and runs only the stages the source did not perform. |
| `onQueryChange` | `onQueryChange?: ((previous: DataQuery, next: DataQuery, ctx: ModuleContext<Row>) => void);` | optional, inherited | Called after the effective query changed (sort, filter, search, page, group). Runs inside the dispatch of the command that changed it; may dispatch commands through `ctx` (selection clears itself here when it does not persist). |
| `onConnect` | `onConnect?: ((ctx: ModuleContext<Row>) => void);` | optional, inherited | `engine.connect()` ran (`deferDataSource`): start loads that were held while disconnected. |
| `onSourceEvent` | `onSourceEvent?: ((event: DataSourceEvent<Row>, state: RowPinningState, ctx: ModuleContext<Row>) => boolean);` | optional, inherited | A data source event (patch or reset). Return true to consume it: the engine then leaves its source rows unchanged (infinite scroll applies write echoes to the blocks it owns). |
| `dispose` | `dispose?: (() => void);` | optional, inherited |  |

### RowPinningPinCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/RowPinningPinCommand

```ts
type RowPinningPinCommand = {
    type: 'rowPinning.pin';
    rowIds: RowId[];
};
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowPinning.pin';` |  |  |
| `rowIds` | `rowIds: RowId[];` |  |  |

### RowPinningSetCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/RowPinningSetCommand

```ts
type RowPinningSetCommand = {
    type: 'rowPinning.set';
    pinned: RowId[];
    unpinned?: RowId[];
};
```

Replaces the explicit pins and unpins (state restore).

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowPinning.set';` |  |  |
| `pinned` | `pinned: RowId[];` |  |  |
| `unpinned` | `unpinned?: RowId[];` | optional |  |

### RowPinningUnpinCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-pinning/RowPinningUnpinCommand

```ts
type RowPinningUnpinCommand = {
    type: 'rowPinning.unpin';
    rowIds: RowId[];
};
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowPinning.unpin';` |  |  |
| `rowIds` | `rowIds: RowId[];` |  |  |
