Selection Basics
The Angular Grid enables the user to select single or multiple cells and rows. It provides a rich API for customizing the selection logic and persisting the selected items based on specific requirements.
Setup
To enable the selection, configure the selectable option. It accepts both boolean and SelectableSettings parameters.
If you use a SelectableSettings parameter, the Kendo UI Grid for Angular enables you to specify the following options:
enabled—Determines if the selection is initially enabled. The default value istrue.checkboxOnly—Determines if the row selection is possible only when the user clicks a checkbox which utilizes theSelectionCheckboxDirective. The default value isfalse.mode—Sets theSelectableModeof the selection. The default value ismultiple.cell—Enables the cell selection. The default value isfalse.drag—Enables the drag selection. The default value isfalse.
The Grid selects only the items on the current page. To select all items across pages or persist selection with virtual scrolling, refer to select all rows or persist range selection with virtual scrolling.
The following articles cover common selection scenarios:
Toggling Selection Dynamically
To control the selection state dynamically, bind the selectable option to a component property:
<button (click)="toggleSelection()">Toggle Selection</button>
<kendo-grid [data]="gridData" [selectable]="isSelectable">
...
</kendo-grid>When using the SelectionDirective, you can disable the initial selection while maintaining the ability to enable it later. Pass a SelectableSettings object with enabled set to false:
<kendo-grid ...
[selectable]="selectableSettings"
kendoGridSelectBy="ProductID"
[(selectedKeys)]="mySelection">
...
</kendo-grid>Handling Selection Changes
When the user modifies the selection the Grid emits a selectionChange event returning a SelectionEvent object. This object contains information about the current selection state, including the selected and deselected items.
Use this event to update external UI elements, calculate totals or aggregates (for more information, see the Selection Aggregates section), enable or disable actions based on the number of selected items, or track user selection behavior.