---
title: "Row Selection"
framework: angular
version: "36.1.0"
---

# Row Selection

Configure the grid to allow users to select rows by clicking them, focusing a row and pressing `␣ Space` or via API.

## Enabling Row Selection

Row selection is configured with the `rowSelection` grid property. Setting `rowSelection.mode` to either `'multiRow'` or `'singleRow'` will allow you to select rows by clicking, focusing a row and pressing `␣ Space`, or via the selection API.

```ts
<ag-grid-angular
    [rowSelection]="rowSelection"
    /* other grid options ... */ />

this.rowSelection = {
    mode: 'singleRow',
};
```

The following example illustrates a basic row selection configuration. Use the select control to choose the default single row or multi-row configuration.

See detailed documentation on the two row selection modes:

- [Single Row Selection](https://www.ag-grid.com/angular-data-grid/row-selection-single-row/)
- [Multi-Row Selection](https://www.ag-grid.com/angular-data-grid/row-selection-multi-row/)

#### Enabling Row Selection

```ts
import { Component } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { AgGridAngular } from "ag-grid-angular";
import "./styles.css";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  GridReadyEvent,
  ModuleRegistry,
  RowSelectionMode,
  RowSelectionModule,
  RowSelectionOptions,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnMenuModule,
  ColumnsToolPanelModule,
  ContextMenuModule,
  RowGroupingModule,
} from "ag-grid-enterprise";
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  RowSelectionModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  ColumnMenuModule,
  ContextMenuModule,
  RowGroupingModule,
]);
import { IOlympicData } from "./interfaces";

@Component({
  selector: "my-app",
  standalone: true,
  imports: [AgGridAngular],
  template: `<div class="example-wrapper">
    <div class="example-header">
      <label>
        <span>Selection mode: </span>
        <select id="input-selection-mode" (change)="updateSelectionOptions()">
          <option value="singleRow">singleRow</option>
          <option value="multiRow">multiRow</option>
        </select>
      </label>
    </div>
    <ag-grid-angular
      style="width: 100%; height: 100%;"
      [columnDefs]="columnDefs"
      [defaultColDef]="defaultColDef"
      [rowSelection]="rowSelection"
      [rowData]="rowData"
      (gridReady)="onGridReady($event)"
    />
  </div> `,
})
export class AppComponent {
  private gridApi!: GridApi<IOlympicData>;

  columnDefs: ColDef[] = [
    { field: "athlete", minWidth: 150 },
    { field: "age", maxWidth: 90 },
    { field: "country", minWidth: 150 },
    { field: "year", maxWidth: 90 },
    { field: "date", minWidth: 150 },
    { field: "sport", minWidth: 150 },
    { field: "gold" },
    { field: "silver" },
    { field: "bronze" },
    { field: "total" },
  ];
  defaultColDef: ColDef = {
    flex: 1,
    minWidth: 100,
  };
  rowSelection: RowSelectionOptions | "single" | "multiple" = {
    mode: "singleRow",
  };
  rowData!: IOlympicData[];

  constructor(private http: HttpClient) {}

  updateSelectionOptions() {
    this.gridApi.setGridOption("rowSelection", {
      mode: getSelectValue("#input-selection-mode"),
    });
  }

  onGridReady(params: GridReadyEvent<IOlympicData>) {
    this.gridApi = params.api;

    this.http
      .get<
        IOlympicData[]
      >("https://www.ag-grid.com/example-assets/small-olympic-winners.json")
      .subscribe((data) => (this.rowData = data));
  }
}

function getSelectValue(id: string): RowSelectionMode {
  return (
    (document.querySelector<HTMLSelectElement>(id)
      ?.value as RowSelectionMode) ?? "singleRow"
  );
}
```

[Live example: Enabling Row Selection](https://www.ag-grid.com/examples/row-selection/enabling-row-selection/angular)

## Row Selection with Enterprise Features

Row selection can be used when using row grouping, tree data and the server-side row model. See the respective sections of the documentation:

- [Row Group Selection](https://www.ag-grid.com/angular-data-grid/grouping-row-selection/)
- [Tree Data Selection](https://www.ag-grid.com/angular-data-grid/tree-data-selection/)
- [Server-Side Row Model Selection](https://www.ag-grid.com/angular-data-grid/server-side-model-selection/)
