# GridRowRef

Fields, allowed values, and APIs that use GridRowRef.

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

<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 GridRowRef<
  TData = GridData,
  TContext = unknown,
> extends GridLiveRef<TData> {
  readonly id: GridRowId;
  getSourceIndex(): number | null;
  getDisplayIndex(): number | null;
  getData(): Readonly<TData> | null;
  getParent(): GridRowRef<TData, TContext> | null;
  getChildren(): ReadonlyArray<GridRowRef<TData, TContext>>;
  isGroup(): boolean;
  isLeaf(): boolean;
  isMaster(): boolean;
  isDetail(): boolean;
  getLevel(): number;
  getRoute(): readonly string[];
  isSelected(): boolean;
  isExpanded(): boolean;
  setSelected(selected: boolean): Promise<boolean>;
  setExpanded(expanded: boolean): Promise<boolean>;
  setData(data: TData): Promise<boolean>;
  updateData(patch: Partial<TData>): Promise<boolean>;
  setValue<TField extends GridFieldPath<TData>>(
    field: TField,
    value: GridPathValue<TData, TField>,
  ): Promise<boolean>;
  setHeight(height: number | null): Promise<boolean>;
  focus(field?: GridFieldPath<TData>): Promise<boolean>;
  startEditing(field: GridFieldPath<TData>): Promise<boolean>;
}
```

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

## APIs using this type

- [getRow](https://grid.syidax.com/docs/methods/getRow.md) — Finds a row object by stable row ID, rather than display index.
- [getDisplayedRowAtIndex](https://grid.syidax.com/docs/methods/getDisplayedRowAtIndex.md) — Finds a row object by its current display index. Sorting, filtering, and grouping can change the row at an index.
- [forEachRow](https://grid.syidax.com/docs/methods/forEachRow.md) — Runs a callback for each row object. Use forEachDisplayedRow when display order matters.
- [forEachDisplayedRow](https://grid.syidax.com/docs/methods/forEachDisplayedRow.md) — Iterates current displayed rows for app features that distinguish source order from display order.

<a id="parents"></a>

## Contracts containing this type

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

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

## Related types

- [GridData](https://grid.syidax.com/docs/types/GridData.md)
- [GridLiveRef](https://grid.syidax.com/docs/types/GridLiveRef.md)
- [GridRowId](https://grid.syidax.com/docs/types/GridRowId.md)
- [GridFieldPath](https://grid.syidax.com/docs/types/GridFieldPath.md)
- [GridPathValue](https://grid.syidax.com/docs/types/GridPathValue.md)
