# Table Layouts - Row Selection

Canonical page: https://www.adaptabletools.com/docs/handbook-layouts-table-row-selection

- Layouts include Row Selection capabilities
- These include ability to set single or multi row selection and to configure row selection behaviour
- Users are able to define the look and feel of the automated Row Selection Column
- Per-row checkbox visibility can be controlled via Layout Options (`isRowSelectionCheckboxVisible`)

[Layouts](https://www.adaptabletools.com/docs/handbook-layouts/index.md) · [Table Layouts](https://www.adaptabletools.com/docs/handbook-layouts-table/index.md) · [All Table Layout Topics](https://www.adaptabletools.com/docs/handbook-layouts-table/index.md#table-layout-topics)

Layouts in AdapTable include comprehensive and configurable Row Selection capabilities.

Configure this on the Layout via `RowSelection` — not on AG Grid `gridOptions.rowSelection`. That keeps selection **per Layout** (each Layout can use a different mode or checkbox setup) and is what the [Layout Editor](https://www.adaptabletools.com/docs/handbook-layouts-wizard-table/index.md) edits.

The `RowSelection` property allows you to set:

- Mode - select only a Single Row or Multiple Rows
- Whether to display a dedicated Selection Column
- Option to display a Checkbox in Header of Selection Column
- Position, Pinning and Size of Selection Column
- Selection / deselection behaviour when clicking elsewhere in a Row
- Row Grouping options (e.g. to put checkboxes in Grouped Column or dedicated Column)
- Per-row checkbox visibility (via `layoutOptions.isRowSelectionCheckboxVisible`)

This page covers **how rows are selected** in a Layout (mode, checkboxes, click behaviour). For selecting cells, the Selection API, Selection Changed events, exporting selected data and Cell Summaries, see [Selecting Grid Data](https://www.adaptabletools.com/docs/handbook-selecting/index.md)

## Using Layout (not GridOptions)

Prior to [AdapTable 22.1](https://www.adaptabletools.com/support/version-221-release-note), Row Selection was configured entirely using AG Grid `GridOptions`.

That is no longer the recommended path. New work should set `RowSelection` on the Layout and leave `gridOptions.rowSelection` unset.

There are 3 options when setting the value for the `RowSelection` property in a Layout:

| Value                | Description                                                                                         |
| -------------------- | --------------------------------------------------------------------------------------------------- |
| `LayoutRowSelection` | Use the Layout object — **this is the recommended option**                                          |
| `false`              | No row selection in this Layout (any `gridOptions.rowSelection` is ignored)                         |
| `undefined`          | Layout does not configure selection; AdapTable falls back to `gridOptions.rowSelection` if provided |

The `undefined` fallback exists so existing apps that still set `gridOptions.rowSelection` keep working. Do not add new selection config there.

Once a Layout sets `RowSelection` (or `false`), those values win over `gridOptions.rowSelection`

### Defining a Layout with Row Selection

Row Selection is defined in the Layout using the `RowSelection` property.

This contains a number of configurable options (see relevant sections below for full details of the available options and values).

`RowSelection` is of type [`LayoutRowSelection`](https://www.adaptabletools.com/docs/reference/layoutrowselection.md) and contains many properties.

This replaces anything set in `rowSelection` prop in AG Grid GridOptions.

The Mode can be either `singleRow` or `multiRow`

AG Grid can display a Checkbox column seting one of 2 properties:

- `Checkboxes` - puts a checkbox in each Row
- `HeaderCheckbox` - renders checkbox also in Column Header

Set whether you want to allow row selection or deselection by clicking / ctrl+clicking in Row

Set Row Selection when Row Grouping through 2 properties:

- `CheckboxInGroupColumn` - checkboxes in Row Grouped or dedicated Column
- `GroupSelectMode` - what is selected when a Group Row is checked

```ts [[1, 9, "RowSelection"], [2, 10, "Mode"], [3, 11, "Checkboxes"], [3, 12, "HeaderCheckbox"], [4, 13, "EnableClickSelection"], [5, 14, "CheckboxInGroupColumn"], [5, 15, "GroupSelectMode"]]
const initialState: InitialState = {
 Layout: {
    CurrentLayout: 'Table Layout',
    Layouts: [
    {
      Name: 'Table Layout',
      TableColumns: ['name', 'updated_at', 'language', 'open_pr_count'],
      RowGroupedColumns: ['license'],
      RowSelection: {
        Mode: 'multiRow',
        Checkboxes: true,
        HeaderCheckbox: true,
        EnableClickSelection: true,
        CheckboxInGroupColumn: false,
        GroupSelectMode: 'descendants',
      },
    }
  }]
},
```

### The Layout Row Selection Object and AG Grid Equivalents

The [`LayoutRowSelection`](https://www.adaptabletools.com/docs/reference/layoutrowselection.md) object is defined as follows:

| Property | Type | Description | Default |
| --- | --- | --- | --- |
| [Checkboxes](https://www.adaptabletools.com/docs/reference/layoutrowselection.md#checkboxes) | `boolean` | Whether to display checkboxes in Selection Column.<br/>Overridden by `LayoutOptions.isRowSelectionCheckboxVisible` when that function is provided<br/>(except when `RowSelection` is `false`, which disables selection entirely). | true |
| [CheckboxInGroupColumn](https://www.adaptabletools.com/docs/reference/layoutrowselection.md#checkboxingroupcolumn) | `boolean` | Renders selection checkboxes in Auto-Group Column (if `true`) or in dedicated Selection Column (if `false`) | false |
| [EnableClickSelection](https://www.adaptabletools.com/docs/reference/layoutrowselection.md#enableclickselection) | `boolean \| 'enableDeselection' \| 'enableSelection'` | Selection behaviour when clicking a row: &#39;enableSelection&#39; \| &#39;enableDeselection&#39; \| true \| false | false |
| [GroupSelectMode](https://www.adaptabletools.com/docs/reference/layoutrowselection.md#groupselectmode) | `GroupSelectionMode` | Grouping Select Mode: &#39;self&#39; \| &#39;descendants&#39; \| &#39;filteredDescendants&#39; | &#39;self&#39; |
| [HeaderCheckbox](https://www.adaptabletools.com/docs/reference/layoutrowselection.md#headercheckbox) | `boolean` | Whether to show checkbox in Header of Selection Column Header (&#39;multiRow&#39; only) | true |
| [Mode](https://www.adaptabletools.com/docs/reference/layoutrowselection.md#mode) | `'singleRow' \| 'multiRow'` | Row Selection Mode: &#39;singleRow&#39; or &#39;multiRow&#39; |   |
| [SelectAllMode](https://www.adaptabletools.com/docs/reference/layoutrowselection.md#selectallmode) | `SelectAllMode` | Select All Mode: &#39;all&#39; \| &#39;filtered&#39; \| &#39;currentPage&#39; | &#39;all&#39; |

The properties in the [`LayoutRowSelection`](https://www.adaptabletools.com/docs/reference/layoutrowselection.md) object all have equivalents in the AG Grid `rowSelection` object (see [AG Grid Row Selection Docs](https://www.ag-grid.com/javascript-data-grid/row-selection/)), and some properties are actual AG Grid objects:

| Property                | AG Grid Equivalent     | Is AG Grid object |
| ----------------------- | ---------------------- | :---------------: |
| `Mode`                  | `mode`                 |        ❌         |
| `Checkboxes`            | `checkboxes`           |        ❌         |
| `CheckboxInGroupColumn` | `checkboxLocation`     |        ❌         |
| `GroupSelectMode`       | `groupSelects`         |        ✅         |
| `SelectAllMode`         | `selectAll`            |        ✅         |
| `HeaderCheckbox`        | `headerCheckbox`       |        ❌         |
| `EnableClickSelection`  | `enableClickSelection` |        ✅         |

## Mode

The (mandatory) Mode property in the [`LayoutRowSelection`](https://www.adaptabletools.com/docs/reference/layoutrowselection.md) object has 2 optional values:

- `singleRow` - only one Row can be selected in the Grid at any time
- `multiRow` - many Rows can be selected in the Grid

**Example: Table Layouts: Row Selection Mode**

Setting Row Selection Mode in a Layout

- This demo contains 2 Layouts, one which provides Single Row Selection, and the other which provides Multi Row Selection

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Table Layouts Row Selection Mode',
  initialState: {
    Dashboard: {
      ModuleButtons: ['Layout'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['Layout'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Single Row Selection',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Single Row Selection',
          RowSelection: {
            Mode: 'singleRow',
            Checkboxes: true,
          },
          AutoSizeColumns: true,
        },
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Multi Row Selection',
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
          },
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Row Selection Column

By default, if Row Selection is enabled, AG Grid automatically creates a dedicated Selection Column.

AdapTable will include this Column in the [Layout Editor](https://www.adaptabletools.com/docs/handbook-layouts-wizard-table/index.md) to enable positioning, pinning and width (see below)

### Checkboxes

This Selection Column is only created if one of 2 properties in the `RowSelection` object is set to true:

| Property         | Description                                                     | Default value |
| ---------------- | --------------------------------------------------------------- | :-----------: |
| `Checkboxes`     | Displays checkbox in each cell in the Column                    |    `true`     |
| `HeaderCheckbox` | Displays checkbox in the Column Header to facilitate Select All |    `true`     |

- If both of these properties are set to *false* then no Selection Column will be displayed
- The Header Checkbox only appears if the Mode is set to '*multiRow*'
- `Checkboxes` is a Layout-level boolean only; for **per-row** visibility see [Checkbox Visibility](#checkbox-visibility) below

**Example: Table Layouts: Row Selection Checkboxes**

Defining Row Selection Column in a Layout

- This demo contains 3 Layouts each with different checkbox configurations:
  - `No Checkboxes` - no Checkboxes in Rows but a Checkbox in the Header
  - `No Checkbox Header` - Checkboxes in Rows but no Checkbox in the Header
  - `No Header or Checkboxes` - the Selection Column is not created at all (as both properties are set to *false*)

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Table Layouts Row Selection Checkboxes',
  initialState: {
    Dashboard: {
      ModuleButtons: ['Layout'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['Layout'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'No Checkboxes',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'No Checkboxes',
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: false,
            HeaderCheckbox: true,
          },
          AutoSizeColumns: true,
        },
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'No Checkbox Header',
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: false,
          },
          AutoSizeColumns: true,
        },
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'No Header or Checkboxes',
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: false,
            HeaderCheckbox: false,
          },
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

### Checkbox Visibility

The `LayoutRowSelection.Checkboxes` property in Layout State sets checkbox visibility for every row in the Layout.

For some use cases, this is too broad-brushed which is why AdapTable also provides dynamic **per-row** checkbox visibility.

This allows you easily to hide checkboxes on empty rows, or grand total rows, or simply based on row data

This is done using the `isRowSelectionCheckboxVisible` property in [Layout Options](https://www.adaptabletools.com/docs/technical-reference-layouts/index.md).

### `isRowSelectionCheckboxVisible`

Configures which Rows display a Selection checkbox

When provided, this function is the **highest precedence** source for AG Grid `rowSelection.checkboxes`. It overrides:

- `LayoutRowSelection.Checkboxes`
- `gridOptions.rowSelection.checkboxes`

It also forces AG Grid `hideDisabledCheckboxes: true`, so returning `false` **hides** the checkbox (rather than greying it out).

It does **not** apply when the Layout sets `RowSelection: false` (row selection is fully disabled for that Layout).

Returning `false` hides the checkbox and prevents selecting that Row via the checkbox. Click-to-select still follows `EnableClickSelection` (default `false`).

```ts
isRowSelectionCheckboxVisible?: (context: LayoutRowSelectionContext) => boolean;
```

The function receives a [`LayoutRowSelectionContext`](https://www.adaptabletools.com/docs/reference/layoutrowselectioncontext.md) object:

| Property | Type | Description |
| --- | --- | --- |
| [data](https://www.adaptabletools.com/docs/reference/layoutrowselectioncontext.md#data) | `TData \| undefined` | The data in the Row Node.<br/>`undefined` for group, footer, pinned, and other non-data rows — use `rowNode` for those cases. |
| [layout](https://www.adaptabletools.com/docs/reference/layoutrowselectioncontext.md#layout) | [`Layout`](https://www.adaptabletools.com/docs/reference/layout.md) | Current Layout |
| [rowNode](https://www.adaptabletools.com/docs/reference/layoutrowselectioncontext.md#rownode) | `IRowNode<TData>` | The Row Node being evaluated |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/layoutrowselectioncontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

Use `context.rowNode` for group, footer, pinned and total rows — `data` may be `undefined` for those.

```ts {3-6}
const adaptableOptions: AdaptableOptions = {
  layoutOptions: {
    isRowSelectionCheckboxVisible: (context: LayoutRowSelectionContext) => {
      // Hide checkboxes on empty / total rows and non-JavaScript languages
      return Boolean(context.data) && context.data.language === 'JavaScript';
    },
  },
};
```

**Example: Row Selection Checkbox Visibility**

Hiding Selection checkboxes for specific Rows via Layout Options

- This demo sets `isRowSelectionCheckboxVisible` in Layout Options so Checkboxes only appear for rows where `Language` is *JavaScript*
- Layout `RowSelection.Checkboxes` property is set to `true` (so all rows show a Checkbox by default); the function provides per-row overrides where rows returning `false` hide the Checkbox

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {
  AdaptableOptions,
  LayoutRowSelectionContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Row Selection Checkbox Visibility',
  layoutOptions: {
    // Only show selection checkboxes for JavaScript rows (and hide for empty / non-data rows)
    isRowSelectionCheckboxVisible: (
      context: LayoutRowSelectionContext<WebFramework>
    ) => {
      return Boolean(context.data) && context.data!.language === 'JavaScript';
    },
  },
  initialState: {
    Dashboard: {
      ModuleButtons: ['Layout'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['Layout'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Per-Row Checkboxes',
      Layouts: [
        {
          Name: 'Per-Row Checkboxes',
          TableColumns: [
            'ag-Grid-SelectionColumn',
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'week_issue_change',
          ],
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
          },
          ColumnSizing: {
            'ag-Grid-SelectionColumn': {
              Width: 50,
            },
          },
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

### Position

By default AG Grid will place the Selection Column on the left of the Grid as the first Column.

However it is possible to position the Selection Column anywhere in the Grid.

This is done by explicitly referencing the Column in the `TableColumns` property in the Layout.

You need to explicitly refer to the Column using the AG Grid provided Id: `ag-Grid-SelectionColumn`

**Example: Table Layouts: Row Selection Position**

Positioning Row Selection Column in a Layout

- In this example the Layout has a Selection Column which is placed between `Language` and `Github Stars` Columns (instead of default position on left)

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Table Layouts Row Selection Position',
  initialState: {
    Dashboard: {
      ModuleButtons: ['Layout'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['Layout'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Placed Selection Column',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'ag-Grid-SelectionColumn',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Placed Selection Column',
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
          },
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

### Pinning

It is also possible to pin the Row Selection Column if required.

Again, this is done by explicitly referencing the Column by its AG Grid provided Id of `ag-Grid-SelectionColumn`, this time in the `ColumnPinning` section of the Layout.

If you wish to right-pin the Selection Column, you need explicitly also to reference it in the `TableColumns` property

**Example: Table Layouts: Row Selection Pinning**

Pinning Row Selection Column in a Layout

- In this example there are 2 Layouts each with the Selection Column pinned - one to the left and the other to the right
- The Layout in which Selection Column is right-pinned also references the column in the `TableColumns` property

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Table Layouts Row Selection Pinning',
  initialState: {
    Dashboard: {
      ModuleButtons: ['Layout'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['Layout'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Left Pinned Selection Column',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Left Pinned Selection Column',
          ColumnPinning: {
            'ag-Grid-SelectionColumn': 'left',
          },
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
          },
        },
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'ag-Grid-SelectionColumn', // needs to be explicitly listed (in any position) to right-pin
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Right Pinned Selection Column',
          ColumnPinning: {
            'ag-Grid-SelectionColumn': 'right',
          },
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
          },
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

### Sizing

It is also possible to size the Row Selection Column, by using the ColumnSizing property in the Layout.

Again, this is done by explicitly referencing the Column using the AG Grid Id of `ag-Grid-SelectionColumn`.

In order to size the Selection Column, you must explicitly also to reference it in the `TableColumns` property

**Example: Table Layouts: Row Selection Sizing**

Sizing Row Selection Column in a Layout

- In this example there are 2 Layouts each with the Selection Column sized - one using Width, and the other using Flex
- Both Layouts also reference the Selection Column in the `TableColumns` property

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Table Layouts Row Selection Sizing',
  initialState: {
    Dashboard: {
      ModuleButtons: ['Layout'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['Layout'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Pixel Width Selection Column',
      Layouts: [
        {
          TableColumns: [
            'ag-Grid-SelectionColumn',
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Pixel Width Selection Column',
          ColumnSizing: {
            'ag-Grid-SelectionColumn': {Width: 200},
          },
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
          },
        },
        {
          TableColumns: [
            'ag-Grid-SelectionColumn',
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Flex Width Selection Column',
          ColumnSizing: {
            'ag-Grid-SelectionColumn': {Flex: 1},
          },
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
          },
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Click Selection Behaviour

By default row selection is only triggered by checking / unchecking the checkbox in the Selection Column.

However it is possible to configure selection behaviour by clicking anywhere in the Row.

This is achieved by setting the `EnableClickSelection` property, which can be one of 4 values:

| Property Value          | Behaviour                                                                     |
| ----------------------- | ----------------------------------------------------------------------------- |
| `enableSelection`       | Allows selection of a Row by clicking in the row itself                       |
| `enableDeselection`     | Allows deselection of a Row by CTRL-clicking in the row itself                |
| `true`                  | Allows selection of a row by clicking & deselection of a row by CTRL-clicking |
| `false` (default value) | Prevents rows from being selected or deselected by clicking in them           |

- If the value is `enableSelection`, clicking in the Row will automatically deselect any currently selected Rows
- This is AG Grid default behaviour (which we support): you must click in the checkboxes to select multiple rows 

**Example: Table Layouts: Row Selection Click Behaviour**

Setting Click Behaviour for a Row Selection Column

- This example contains 4 Layouts each of which has a different values for the `EnableClickSelection` property:
  - `Default Click Selection` - set to `false` so there is no in-row selection
  - `Full Click Selection` - set to `true` so rows can be selected (by click) and deselected (by ctrl+click)
  - `Enable Selection Only` - set to `enableSelection` so rows can be selected (by click) 
  - `Enable Deselection Only` - set to `enableDeselection` so rows can deselected (by ctrl+click)

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Table Layouts Row Selection Click Behaviour',
  initialState: {
    Dashboard: {
      ModuleButtons: ['Layout'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['Layout'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Default Click Selection',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Default Click Selection',
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
            EnableClickSelection: false, // default value
          },
          AutoSizeColumns: true,
        },
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Full Click Selection',
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
            EnableClickSelection: true,
          },
          AutoSizeColumns: true,
        },
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Enable Selection Only',
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
            EnableClickSelection: 'enableSelection',
          },
          AutoSizeColumns: true,
        },
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Enable Deselection Only',
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
            EnableClickSelection: 'enableDeselection',
          },
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Row Grouping

Row Selection also works fully when [Row Grouping](https://www.adaptabletools.com/docs/handbook-grouping-rows/index.md) is active in the Grid.

AdapTable provides 2 useful configuration options in Layout Row Selection relating to Grouping.

### Checkbox Placement

When Row Grouping, its possible to configure where the Selection checkboxes appear.

This is done via the boolean `CheckboxInGroupColumn` property which behaves as follows:

- set to _true_ - the Checkboxes appear in the Row Grouped Column itself
- set to _false_ - the Checkboxes appear in a dedicated Selection Column

### Selection Behaviour

Additionally its possible to configure what is selected when a checkbox is clicked in a [Grouped Row](https://www.adaptabletools.com/docs/handbook-grouping-rows-grouped-rows/index.md).

This is done via the `GroupSelectMode` property which has 3 possible values:

- `self` (default value) - only the Grouped Row itself is selected
- `descendants` - the Grouped Row and all associated leaf rows are selected
- `filteredDescendants` - the Grouped Row and all currently filtered leaf rows are selected

- Similarly, it is possible to configure the "Select All" behaviour (when clicking the Header Checkbox)
- The `SelectAllMode` property can be set to select All Rows, Filtered Rows, or rows in the Current Page only

**Example: Table Layouts: Row Selection with Row Grouping**

Configuring Row Selection while Row Grouping

- This example contains 3 Layouts each of which shows different row grouping behaviours:
  - `Checkbox in Group Column` - `CheckboxInGroupColumn` is set to *true* so the Checkboxes appear in the Row Grouped Columns
  - `Checkbox in Dedicated Selection Column` - `CheckboxInGroupColumn` is set to *false* so the Checkboxes appear in the dedicated Selection Column
  - `All Descendants Selected` - `GroupSelectMode` is set to `descendants`, so clicking a Grouped Row checks all leaf rows (its set to *false* in other 2 Layouts) 

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Table Layouts Row Selection Grouping Column',
  initialState: {
    Dashboard: {
      ModuleButtons: ['Layout'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['Layout'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Checkbox in Group Column',
      Layouts: [
        {
          TableColumns: [
            'name',
            'github_stars',
            'language',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Checkbox in Group Column',
          RowGroupedColumns: ['license'],
          RowGroupValues: {
            RowGroupDefaultBehavior: 'expanded',
          },
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
            CheckboxInGroupColumn: true,
          },
          AutoSizeColumns: true,
        },
        {
          TableColumns: [
            'name',
            'github_stars',
            'language',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Checkbox in Dedicated Selection Column',
          RowGroupedColumns: ['license'],
          RowGroupValues: {
            RowGroupDefaultBehavior: 'expanded',
          },
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
            CheckboxInGroupColumn: false,
          },
          AutoSizeColumns: true,
        },
        {
          TableColumns: [
            'name',
            'github_stars',
            'language',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'All Descendants Selected',
          RowGroupedColumns: ['license'],
          RowGroupValues: {RowGroupDefaultBehavior: 'expanded'},
          RowSelection: {
            Mode: 'multiRow',
            Checkboxes: true,
            HeaderCheckbox: true,
            CheckboxInGroupColumn: true,
            GroupSelectMode: 'descendants',
          },
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

### FAQ

**Should I set `rowSelection` in AG Grid GridOptions?**
No — configure Row Selection on the Layout. `gridOptions.rowSelection` is only a fallback when a Layout leaves `RowSelection` undefined.

**Can I combine Row Selection properties in Grid Options and AdapTable Layout?**
Do not mix them. If the Layout sets `RowSelection` (or `false`), those values win. If `RowSelection` is omitted, GridOptions is used.

**How do I hide Selection checkboxes for specific rows (e.g. totals / empty rows)?**
Use `layoutOptions.isRowSelectionCheckboxVisible`. Layout State only supports a boolean `Checkboxes` property (so Layouts remain serializable); per-row logic belongs in Layout Options and overrides both Layout and GridOptions checkbox settings. See [Checkbox Visibility](#checkbox-visibility) above.
