# Row Selection

The [Angular Grid](https://www.telerik.com/kendo-angular-ui/components/grid) provides the user with multiple interaction options to select rows, which are:

<Row>
  <Column count={[24,24,8]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#single-row-selection">
      <ComponentTitle>Single Row Selection</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Enable users to select one row at a time using click, checkbox, or keyboard navigation.</ComponentDescription>
    </Component>
  </Column>
  <Column count={[24,24,8]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#multiple-rows-selection">
      <ComponentTitle>Multiple Rows Selection</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Select multiple rows individually, in ranges, or with drag selection using keyboard modifiers.</ComponentDescription>
    </Component>
  </Column>
  <Column count={[24,24,8]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#checkbox-only-selection">
      <ComponentTitle>Checkboxes-Only Selection</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Restrict row selection to checkboxes only, preventing selection through row clicks.</ComponentDescription>
    </Component>
  </Column>
  <Column count={[24,24,8]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#select-all-checkbox">
      <ComponentTitle>Select-All Checkbox</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Add a header checkbox to select or deselect all items on the current page.</ComponentDescription>
    </Component>
  </Column>
  <Column count={[24,24,8]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#multiple-row-selection-for-mobile-devices">
      <ComponentTitle>Multiple Row Selection for Mobile Devices</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Configure touch-friendly selection without requiring modifier keys for mobile users.</ComponentDescription>
    </Component>
  </Column>
  <Column count={[24,24,8]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#disabling-the-selection-for-specific-rows">
      <ComponentTitle>Disabling the Selection for Specific Rows</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Programmatically prevent selection of specific rows based on custom conditions.</ComponentDescription>
    </Component>
  </Column>
</Row>

The following example demonstrates the row selection in action.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/grid/configuration/selection/source.txt)

## Single Row Selection

To select a row in single selection mode, use one of the following actions:

* Click the row.
* Select the row's checkbox.
* Press `Enter` on the row (available only when [Keyboard Navigation](https://www.telerik.com/kendo-angular-ui/components/grid/keyboard-navigation) is enabled).

To deselect a row in single selection mode, use one of the following actions:

* Deselect the checkbox of the selected row.
* Press and hold `Ctrl/Cmd(MacOS)`, then click the selected row.
* Press `Ctrl/Cmd(MacOS) + Enter` on the row (available only when [Keyboard Navigation](https://www.telerik.com/kendo-angular-ui/components/grid/keyboard-navigation) is enabled).

> note Clicking a selected row will not deselect it.

The following example demonstrates how to select or deselect a single row using the actions described above.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/grid/configuration/selection/single-row/source.txt)

## Multiple Rows Selection

The following table summarizes the available actions for selecting multiple rows in the Grid:

| Action                           | Description                                                                                                     | Keyboard/Mouse Interaction                                                                                                                                                                                                                                                                                                                                                                              | Requirements                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Select multiple rows one by one  | Select rows individually without affecting other selected rows.                                                 | • Select the checkbox of each desired row.<br>• Press and hold `Ctrl/Cmd(MacOS)`, and click the desired rows.<br>• Press `Ctrl/Cmd(MacOS) + Enter` on the desired rows.                                                                                                                                                                                                                                 | Requires [Keyboard Navigation](https://www.telerik.com/kendo-angular-ui/components/grid/keyboard-navigation) for `Ctrl/Cmd(MacOS) + Enter`.                                                                                                                                                                                                                                                                                                     |
| Select a range of rows           | Select a continuous range of rows by defining a start and end point. Any new selection resets the previous one. | • Click and drag the rectangular selection over the desired rows.<br>• Select a row, then press and hold `Shift` and click the last row in the range.<br>• Press `Enter` to select a row, navigate with arrow keys, and press `Shift + Enter` on the last row.                                                                                                                                          | • Drag selection requires the [`drag`](https://www.telerik.com/kendo-angular-ui/components/grid/api/selectablesettings#metakeymultiselect) option.<br>• Requires [Keyboard Navigation](https://www.telerik.com/kendo-angular-ui/components/grid/keyboard-navigation) for `Shift + Enter`.                                                                                                                                                       |
| Persist multiple range selection | Select multiple ranges of rows without resetting previous selections.                                           | • Press `Ctrl/Cmd(MacOS)` while clicking and dragging the rectangular selection.<br>• Select a row, then press and hold `Shift` and click the last row in the range. Press and hold `Ctrl/Cmd(MacOS)` and repeat for a new range.<br>• Press `Enter` to select a row, navigate with arrow keys, and press `Shift + Enter` on the last row. Press and hold `Ctrl/Cmd(MacOS)` and repeat for a new range. | • Requires [`multipleRanges`](https://www.telerik.com/kendo-angular-ui/components/grid/api/selectablesettings#multipleranges) to be set to `true`.<br>• Drag selection requires the [`drag`](https://www.telerik.com/kendo-angular-ui/components/grid/api/selectablesettings#metakeymultiselect) option.<br>• Requires [Keyboard Navigation](https://www.telerik.com/kendo-angular-ui/components/grid/keyboard-navigation) for `Shift + Enter`. |
| Deselect a row                   | Remove a specific row from the selection.                                                                       | • Deselect the checkbox of the specific row.<br>• Press and hold `Ctrl/Cmd(MacOS)`, then click the specific row.<br>• Press `Ctrl/Cmd(MacOS) + Enter` on the desired row.                                                                                                                                                                                                                               | Requires [Keyboard Navigation](https://www.telerik.com/kendo-angular-ui/components/grid/keyboard-navigation) for `Ctrl/Cmd(MacOS) + Enter`.                                                                                                                                                                                                                                                                                                     |
| Leave only one row selected      | Deselect all previously selected rows and keep only the current row selected.                                   | • Click a row within the Grid.<br>• Press `Enter` to select the active row.                                                                                                                                                                                                                                                                                                                             | Requires [Keyboard Navigation](https://www.telerik.com/kendo-angular-ui/components/grid/keyboard-navigation) for `Enter`.                                                                                                                                                                                                                                                                                                                       |

The following example demonstrates how to select and deselect multiple rows using the action described above.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/grid/configuration/selection/multiple-row/source.txt)

## Multiple Row Selection for Mobile Devices

To ensure its user-friendliness on mobile and touchscreen devices, the Grid exposes the [`metaKeyMultiSelect`](https://www.telerik.com/kendo-angular-ui/components/grid/api/selectablesettings#metakeymultiselect) property which allows you to determine whether pressing the `Ctrl` or `Command` keys is required for the selection of multiple rows at the same time.

The following example demonstrates how to enable the multiple rows selection without using the `Ctrl` and `Command` keys.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/grid/configuration/selection/multiple-row-without-ctrl-shift/source.txt)

## Checkbox-Only Selection

The Grid component provides the ability to select rows only through a dedicated checkbox associated with each respective row.

To enable the checkbox-only selection, define a [`CheckboxColumnComponent`](https://www.telerik.com/kendo-angular-ui/components/grid/api/checkboxcolumncomponent) in the Grid and set the [`checkboxOnly`](https://www.telerik.com/kendo-angular-ui/components/grid/api/selectablesettings#checkboxonly) property of the `SelectableSettings` object to `true`.

```HTML
<kendo-grid
  [data]="gridData"
  [selectable]="{ checkboxOnly: true }"
>
    <kendo-grid-checkbox-column [width]="40"></kendo-grid-checkbox-column>
    ...
</kendo-grid>
```

You can combine the checkbox-only selection with single or multiple selection mode. To select rows in the Grid when checkbox-only selection is enabled, use the checkboxes of the desired rows.

The following example demonstrates checkbox-only selection with the built-in checkbox column.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/grid/configuration/selection/checkbox-only/source.txt)

## Customizing Checkbox Selection

To customize the built-in checkbox selection of the Grid, use the [`SelectionCheckboxDirective`](https://www.telerik.com/kendo-angular-ui/components/grid/api/selectioncheckboxdirective) and apply it to a `<kendo-checkbox>` component within a cell template. The directive keeps the checkbox connected to the Grid selection state while you control the content and layout of the cell.

Use a custom checkbox template when the selector must convey row-specific context or a workflow action instead of a generic selection. For example, use a custom template to:

* Add a business action next to the checkbox, such as **Add to order**, **Approve**, or **Assign**.
* Display contextual information, such as an approval state, a fulfillment status, or the reason that a row is unavailable.
* Render a checkbox only for eligible rows and pair it with the [`isRowSelectable`](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent#isrowselectable) callback to enforce the same rule.

The following example lets inventory managers add only items below their reorder level to a replenishment order. It renders an **Add to order** checkbox for eligible items and a **Stocked** state for all other items.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/grid/configuration/selection/custom-checkbox-selection/source.txt)

> tip To prevent `Enter` from changing row selection when a checkbox has focus, see [Prevent Grid Checkbox Selection with the Enter Key](https://www.telerik.com/kendo-angular-ui/components/knowledge-base/prevent-grid-checkbox-selection-enter).

## Select-All Checkbox

The Grid allows the selection or deselection of all items on a page through a select-all checkbox in its header. To enable the select-all feature, set the [`showSelectAll`](https://www.telerik.com/kendo-angular-ui/components/grid/api/checkboxcolumncomponent#showselectall) option of [`CheckboxColumnComponent`](https://www.telerik.com/kendo-angular-ui/components/grid/api/checkboxcolumncomponent) to `true`. You can also manually add a select-all checkbox to a template by utilizing the [`SelectAllCheckboxDirective`](https://www.telerik.com/kendo-angular-ui/components/grid/api/selectallcheckboxdirective).

> The select-all feature applies only to the items that are rendered on the current page when paging or virtual scrolling is enabled. For more information on how to select all rows across pages, refer to the [Select All Rows](https://www.telerik.com/kendo-angular-ui/components/grid/selection/persisting#selecting-all-rows) article.

The following example demonstrates how to apply the default behavior of the select-all checkbox and select all items on the page.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/grid/configuration/selection/select-all-checkbox/source.txt)

## Disabling the Selection for Specific Rows

The Grid enables you to determine which of its rows can be selected depending on certain conditions. To programmatically specify the rows which can be selected, use the built-in [`isRowSelectable`](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent#isrowselectable) function. The callback is executed for all rows in the component and returns a boolean value which determines whether the row can be selected or not.

When the cell selection is enabled, the non-selectable rows are still respected and their cells cannot be selected.

To hide the checkboxes of the rows with disabled selection from the designated checkbox column, set the value of its [`showDisabledCheckbox`](https://www.telerik.com/kendo-angular-ui/components/grid/api/checkboxcolumncomponent#showdisabledcheckbox) property to `false`.

The following example demonstrates how to disable the selection of specific rows based on a given condition and hide their respective checkboxes.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/grid/configuration/selection/disable-selection-conditionally/source.txt)

## Suggested Links

* [`SelectionDirective`](https://www.telerik.com/kendo-angular-ui/components/grid/api/selectiondirective#selectiondirective)
* [`RowArgs`](https://www.telerik.com/kendo-angular-ui/components/grid/api/rowargs)
* [API Reference of the `GridComponent`](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent)
* [API Index of the Grid](https://www.telerik.com/kendo-angular-ui/components/grid/api)
