# Row Select
URL: https://pro.rv-grid.com/api/row-select/
Source: src/content/docs/api/row-select.md
## Module Extensions

### `ColumnRegular` (Extended from `@revolist/revogrid`)

```ts
interface ColumnRegular {
  /**
       * Enables checkbox on cells and columns
       */
      rowSelect?: boolean | ((model: CellTemplateProp) => boolean)
}
```

---

### `AdditionalData` (Extended from `@revolist/revogrid`)

```ts
interface AdditionalData {
  /**
       * Row selection plugin configuration.
       *
       * @deprecated Prefer the direct `grid.rowSelect` property.
       */
      rowSelect?: RowSelectConfig
}
```

---

### `HTMLRevoGridElement` (Extended from `global`)

```ts
interface HTMLRevoGridElement {
  /**
       * Row selection plugin configuration.
       */
      rowSelect?: RowSelectConfig
}
```

---

### `HTMLRevoGridElementEventMap` (Extended from `global`)

```ts
interface HTMLRevoGridElementEventMap {
  /**
       * Header cell with checkbox clicked
       */
      [ROW_ALL_SELECT_EVENT]: RowSelectAllEvent;
  /**
       * Cell with checkbox clicked in the row
       */
      [ROW_SELECT_EVENT]: RowSelectEvent;
  /**
       * When row selection happened. Returns selected objects.
       */
      [ROW_SELECTED_EVENT]: {
        selected: Map<DimensionRows, Set<number>>;
        visibleCount: number;
        visibleRowsCount: number;
        count: number;
        allRowsCount: number;
      }
}
```

## Plugin API

### `DEFAULT_SEL_PROP`

```ts
DEFAULT_SEL_PROP: string;
```

---

### `RowSelectPlugin`

The `RowSelectPlugin` enables checkbox-based row selection.

Quick setup:

```ts
import { RowSelectPlugin } from '@revolist/revogrid-pro';

grid.plugins = [RowSelectPlugin];
grid.columns = [
  { prop: 'select', name: '', rowSelect: true, size: 56 },
  { prop: 'name', name: 'Name' },
];
```

Public configuration:

| API | Default | Meaning |
| --- | --- | --- |
| `ColumnRegular.rowSelect` | `false` | Renders a row checkbox for normal data cells in that column. A function can hide the checkbox for specific cells. |
| `grid.rowSelect` | `{ grouping: false, rowOrder: false }` | Configures optional row-select behavior. Use this for grouping checkboxes and checkbox-driven row ordering. |
| `additionalData.rowSelect` | none | Legacy alias for `grid.rowSelect`. Prefer the direct grid property. |
| `rowSelect.grouping` | `false` | Opt-in checkbox support for RevoGrid grouping rows. Use `true` or `{ enabled: true }`. |
| `rowSelect.rowOrder` | `false` | Opt-in RowOrderPlugin integration. When enabled, dragging a checked row moves visible checked rows before range selection. |

Index and count semantics:

| Term | Meaning |
| --- | --- |
| Data row | A real row from the user source data. |
| Synthetic grouping row | A row generated by RevoGrid grouping. It can render a group checkbox, but it is never stored as selected data. |
| Physical row index | The index stored in `rowselected.detail.selected`. For grouped rows this maps back to the original data row index, not the synthetic group source position. |
| Visible rows | Rows currently visible after filtering, sorting, grouping expansion/collapse, tree expansion/collapse, and row ordering. |
| `count` | Number of selected real data rows across the full data set. |
| `allRowsCount` | Number of selectable real data rows across the full data set. Synthetic grouping rows are excluded. |
| `visibleCount` | Number of selected real data rows currently visible. |
| `visibleRowsCount` | Number of selectable real data rows currently visible. |

Behavior matrix:

| Case | Behavior |
| --- | --- |
| Flat rows | Clicking a row checkbox toggles that data row. Header select-all toggles all currently matching data rows. |
| Shift-click | Selects the visible data-row range between the previous selected row and the clicked row. Synthetic group rows are skipped. |
| Filtering | Selection stays attached to physical data rows. `rowselected` is re-emitted so visible counts reflect the filtered view. |
| Sorting | Selection stays attached to physical data rows after sort order changes. `rowselected` is re-emitted. |
| Row drag | Selection stays attached to physical data rows after row order changes. `rowselected` is re-emitted. |
| Grouping disabled | Group rows do not render checkboxes, even when a row-select column exists. |
| Grouping enabled | Group rows render checkboxes only when a visible row-select column exists. |
| Group checkbox click | Selects or clears all descendant real data rows in that group. Group rows themselves are not selected. |
| Group child roll-up | Some selected children make the group checkbox indeterminate. All selected children make it checked. Ancestor groups update the same way. |
| Collapsed groups | Header select-all toggles matching real data rows, including descendants hidden by collapsed groups. |
| Tree parent click | When `TreeDataPlugin` is registered, clicking a tree parent checkbox toggles that parent and all descendants. |
| Tree child click | Clicking a tree leaf/child without descendants toggles only that row. |
| Checkbox row-order | When `rowSelect.rowOrder` is enabled, dragging a checked row moves visible checked rows as a compact block. Dragging an unchecked row keeps current range/single-row behavior. |

Events:

| Event | Constant | Use it for |
| --- | --- | --- |
| `rowselectclick` | `ROW_SELECT_EVENT` | Internal/plugin integration point for toggling one row. |
| `rowallselectclick` | `ROW_ALL_SELECT_EVENT` | Internal/plugin integration point for toggling all matching selectable rows. |
| `rowselected` | `ROW_SELECTED_EVENT` | Public application event. Read `selected`, `count`, `allRowsCount`, `visibleCount`, and `visibleRowsCount`. |

`rowselected.detail.selected` is a `Map<DimensionRows, Set<number>>` keyed by row type.
The set contains physical indexes for real data rows only.

#### Dependencies

- **Event integration** `tree-data`: Integrates with TreeDataPlugin descendant selection events when present.

```ts
class RowSelectPlugin {
  /**
     * Returns physical selected row indexes
     */
  getSelectedIndexes();

  /**
     * Clears checkbox row selection and updates row/header checkbox state.
     */
  clearSelection(type?: DimensionRows): void;

  /**
     * Returns visible checkbox-selected rows for RowOrderPlugin integration.
     */
  getRowOrderSelection(
    type: DimensionRows,
    draggedVisibleRowIndex: number,
  ): RowSelectRowOrderSelection | null;

  destroy();
}
```

---

### `RowSelectColumnType`

```ts
class RowSelectColumnType {}
```

---

### `normalizeRowSelectConfig`

Normalizes public row selection configuration to the internal shape.

```ts
export function normalizeRowSelectConfig(
  config?: boolean | RowSelectConfig,
): NormalizedRowSelectConfig;
```

---

### `RowSelectGroupingConfig`

Grouped row checkbox configuration for the row selection plugin.

```ts
interface RowSelectGroupingConfig {
  /**
     * Enables checkbox rendering on RevoGrid grouping rows.
     *
     * Disabled by default. When enabled, selecting a group checkbox selects or
     * clears all descendant data rows while synthetic group rows stay out of the
     * selected index set.
     */
    enabled?: boolean
}
```

---

### `RowSelectRowOrderConfig`

Checkbox-selected row-order integration configuration.

```ts
interface RowSelectRowOrderConfig {
  /**
     * Enables RowOrderPlugin integration with checkbox-selected rows.
     *
     * Disabled by default. When enabled, dragging a checked row moves all
     * visible checked rows in the same row viewport as a compact block.
     */
    enabled?: boolean
}
```

---

### `RowSelectConfig`

Row selection plugin configuration.

Set this on `grid.rowSelect`. `additionalData.rowSelect` is supported as a
compatibility alias, but the direct grid property is preferred.

Examples:

```ts
grid.rowSelect = { grouping: true };
grid.rowSelect = { grouping: { enabled: true } };
grid.rowSelect = { grouping: false };
grid.rowSelect = { rowOrder: true };
grid.rowSelect = { rowOrder: { enabled: true } };
```

```ts
interface RowSelectConfig {
  /**
     * Enables row selection integration with RevoGrid grouping.
     *
     * Defaults to `false`. Use `true` for the compact form or
     * `{ enabled: true }` for the future-compatible object form.
     */
    grouping?: boolean | RowSelectGroupingConfig;
  /**
     * Enables checkbox-selected row drag integration with RowOrderPlugin.
     *
     * Defaults to `false`. Use `true` for the compact form or
     * `{ enabled: true }` for the future-compatible object form.
     */
    rowOrder?: boolean | RowSelectRowOrderConfig
}
```

---

### `NormalizedRowSelectConfig`

Internal normalized row selection configuration.

```ts
interface NormalizedRowSelectConfig {
  grouping: {
      enabled: boolean;
    };
  rowOrder: {
      enabled: boolean;
    }
}
```

---

### `DEFAULT_ROW_SELECT_CONFIG`

Default row selection configuration.

Group row checkboxes are opt-in and disabled by default.

```ts
DEFAULT_ROW_SELECT_CONFIG: {
  grouping: { enabled: false; };
  rowOrder: { enabled: false; };
};
```

---

### `isRowSelectGroupingRow`

```ts
export function isRowSelectGroupingRow(row: DataType | undefined): boolean;
```

---

### `getRowSelectIndex`

```ts
export function getRowSelectIndex(
  source: DataType[],
  physicalIndex: number,
): number;
```

---

### `collectGroupLeafIndexes`

```ts
export function collectGroupLeafIndexes(
  source: DataType[],
  groupIndex: number,
  matchesGroupValue: GroupValueMatcher = defaultGroupValueMatcher,
  orderedIndexes?: number[],
): number[];
```

---

### `getGroupSelectionState`

```ts
export function getGroupSelectionState(
  selected: Set<number>,
  source: DataType[],
  groupIndex: number,
): GroupSelectionState;
```

---

### `createGroupSelectionStateLookup`

```ts
export function createGroupSelectionStateLookup(
  selected: Set<number>,
  source: DataType[],
  matchesGroupValue: GroupValueMatcher = defaultGroupValueMatcher,
  orderedIndexes?: number[],
): Map<number, GroupSelectionState>;
```

---

### `getVisibleSelectableIndexes`

```ts
export function getVisibleSelectableIndexes(
  source: DataType[],
  items: number[],
): number[];
```

---

### `countSelectableIndexes`

```ts
export function countSelectableIndexes(
  source: DataType[],
  items: number[],
): number;
```

---

### `countSelectedIndexes`

```ts
export function countSelectedIndexes(
  selected: Set<number>,
  source: DataType[],
): number;
```

---

### `countSelectedVisibleIndexes`

```ts
export function countSelectedVisibleIndexes(
  selected: Set<number>,
  source: DataType[],
  items: number[],
): number;
```

---

### `applySelectionToIndexes`

```ts
export function applySelectionToIndexes(
  selected: Set<number>,
  indexes: number[],
  shouldSelect: boolean,
);
```

---

### `getVisibleSelectionRange`

```ts
export function getVisibleSelectionRange(
  source: DataType[],
  items: number[],
  fromPhysicalIndex: number,
  toPhysicalIndex: number,
): number[];
```

---

### `GroupSelectionState`

```ts
interface GroupSelectionState {
  selected: boolean;
  indeterminate: boolean;
  selectedCount: number;
  totalCount: number
}
```

---

### `ROW_SELECT_ORIGINAL_INDEX`

```ts
ROW_SELECT_ORIGINAL_INDEX: string;
```

---

### `GroupValueMatcher`

```ts
export type GroupValueMatcher = (
  row: DataType,
  prop: ColumnProp,
  value: unknown,
) => boolean;
```

---

### `resolveRowSelectRowOrderSelection`

```ts
export function resolveRowSelectRowOrderSelection(;
```

---

### `RowSelectRowOrderSelection`

```ts
interface RowSelectRowOrderSelection {
  items: Map<number, DataType>;
  rowIndexes: number[]
}
```

---

### `ResolveRowSelectRowOrderSelectionOptions`

```ts
interface ResolveRowSelectRowOrderSelectionOptions {
  draggedVisibleRowIndex: number;
  enabled: boolean;
  selected: Set<number> | undefined;
  source: DataType[];
  visibleItems: number[]
}
```

---

### `RowSelectEvent` (Extended from `index.ts`)

```ts
export type RowSelectEvent = CellTemplateProp & { originalEvent: MouseEvent };
```

---

### `RowSelectAllEvent` (Extended from `index.ts`)

```ts
export type RowSelectAllEvent = ColumnTemplateProp & {
  selected: boolean;
  type: DimensionCols;
};
```

---

### `RowSelectRowOrderProvider`

Runtime contract exposed by RowSelectPlugin for row-order integrations.

```ts
interface RowSelectRowOrderProvider {
  getRowOrderSelection(
      type: DimensionRows,
      draggedVisibleRowIndex: number,
    ): RowSelectRowOrderSelection | null
}
```

---

### `defaultGroupValueMatcher`

```ts
export function defaultGroupValueMatcher(
  row: DataType,
  prop: ColumnProp,
  value: unknown,
): boolean;
```
