# Custom Selection

The [Angular Grid](https://www.telerik.com/kendo-angular-ui/components/grid) provides low-level hooks for implementing custom selection logic.

## Setting the Selected Rows

You can set the selected rows by specifying the [rowSelected](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent#rowselected) function. The function is executed for each data row in the Grid and determines whether the row will be selected.

> The `rowSelected` function takes precedence both over the default selection behavior and over any possibly configured selection option.

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

## Setting the Selected Cells

To set the selected cells programmatically, specify the [cellSelected](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent#cellselected) function. The function is executed for each data cell in the Grid and determines whether the cell will be selected, returning both the selected state, and the respective [CellSelectionItem](https://www.telerik.com/kendo-angular-ui/components/grid/api/cellselectionitem).

> The `cellSelected` function takes precedence both over the default selection behavior and over any possibly configured selection option.

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

## Disabling the Selection of Specific Elements

The Grid automatically handles clicks made on non-focusable elements and performs selection. To disable this default behavior for custom or specific non-focusable elements, apply the `k-grid-ignore-click` class.

```html
<ng-template kendoGridCellTemplate let-dataItem>
    <div
      class="k-grid-ignore-click"
      style="width: 50%;border: 1px solid black;"
    >
      Ignored Element
    </div>
    {{ dataItem.ProductName }}
</ng-template>
```

The following example prevents the row selection when clicking on the custom container displayed inside the cell.

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

## Suggested Links

* [RowArgs](https://www.telerik.com/kendo-angular-ui/components/grid/api/rowargs)
* [rowSelected property](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent#rowselected)
* [cellSelected property](https://www.telerik.com/kendo-angular-ui/components/grid/api/gridcomponent#cellselected)
* [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)
