New to Kendo UI for Angular? Start a free 30-day trial
Selecting All Items within a Grid Group
Environment
Product | Progress® Kendo UI® for Angular Grid |
Description
How to select all items within a group by using a group header checkbox?
Solution
To select all items within a group using a checkbox:
-
Use the
kendoGridGroupHeaderTemplate
directive to display the custom checkbox in the group header.html<ng-template kendoGridGroupHeaderTemplate let-group="group"> <span> <input type="checkbox" kendoCheckBox (input)="onSelectAllChange($event, group)" /> </span> {{ group.field }} </ng-template>
-
Handle the
input
event of the checkbox and manually control the selected items by using theselectedKeys
property of theSelectionDirective
.tspublic onSelectAllChange(e, groupItems) { const checkedState = e.srcElement.checked; if (checkedState === true) { this.mySelection = groupItems.items.map((item) => item.ProductID); } else { this.mySelection = []; } }
The following example demonstrates how to select all rows within a group.
Change Theme
Theme
Loading ...