With Ignite UI for Angular Hierarchical Grid you can easily select data by using variety of events, rich API or with simple mouse interactions like single select.
Angular Grid Selection Example
The sample below demonstrates the three types of Hierarchical Grid's cell selection behavior. Use the buttons below to enable each of the available selection modes. A brief description will be provided on each button interaction through a snackbar message box.
<divclass="grid__wrapper"><divclass="button-group-wrapper"><h6>Parent Grid cell selection mode: </h6><igx-buttongroup [values]="selectionModes" (selected)="selectCellSelectionMode($event)"></igx-buttongroup></div><divclass="button-group-wrapper"><h6>Child Grid cell selection mode: </h6><igx-buttongroup [values]="selectionModesChildren" (selected)="selectCellSelectionModeChildGrid($event)"></igx-buttongroup></div><igx-hierarchical-grid [igxPreventDocumentScroll]="true" #hierarchicalGrid [data]="data" [height]="'560px'" [width]="'100%'" [cellSelection]="selectionMode" #hgrid><igx-columnfield="Artist" [dataType]="'string'"></igx-column><igx-columnfield="HasGrammyAward"header="Has Grammy Award?" [dataType]="'boolean'"></igx-column><igx-columnfield="Debut"dataType="number"></igx-column><igx-columnfield="GrammyNominations"header="Grammy Nominations"dataType="number" [hasSummary]="true"></igx-column><igx-columnfield="GrammyAwards"header="Grammy Awards"dataType="number" [hasSummary]="true"></igx-column><igx-row-island [height]="null" [key]="'Albums'" [cellSelection]="selectionModeChild"><igx-columnfield="Album" [dataType]="'string'"></igx-column><igx-columnfield="LaunchDate"header="Launch Date" [dataType]="'date'"></igx-column><igx-columnfield="BillboardReview"header="Billboard Review"dataType="number"></igx-column><igx-columnfield="USBillboard200"header="US Billboard 200"dataType="number"></igx-column></igx-row-island></igx-hierarchical-grid></div><igx-snackbar #snackbaractionText="Got it. Thanks!" (clicked)="snackbar.close()"><divclass="container"><igx-icon>notification_important</igx-icon><divclass="message-container"><span>Parent grid:</span>
@if (selectionMode === 'multiple') {
<ul><li><b>This is the default selection behavior.</b></li><li>Click on a cell and while pressing the mouse key perform drag action.
</li><li>Select a cell and press Shift + Arrow down key, this will start range selection as well.
</li></ul>
}
@if (selectionMode === 'single') {
<ul><li><b>Now you can select only one cell within the grid.</b></li><li>On single cell click the previous selection state will be cleared.</li><li>The mouse drag will not work and instead of selecting a cell, this will make default text
selection.</li></ul>
}
@if (selectionMode === 'none') {
<ul><li><b>Now you are unable to select a cell while interacting with grid UI.</b></li><li>If you need to select a cell, you can use the grid API methods.</li></ul>
}
</div><divclass="message-container"><span>Child grid:</span>
@if (selectionModeChild === 'multiple') {
<ul><li><b>This is the default selection behavior.</b></li><li>Click on a cell and while pressing the mouse key perform drag action.
</li><li>Select a cell and press Shift + Arrow down key, this will start range selection as well.
</li></ul>
}
@if (selectionModeChild === 'single') {
<ul><li><b>Now you can select only one cell within the grid.</b></li><li>On single cell click the previous selection state will be cleared.</li><li>The mouse drag will not work and instead of selecting a cell, this will make default text
selection.</li></ul>
}
@if (selectionModeChild === 'none') {
<ul><li><b>Now you are unable to select a cell while interacting with grid UI.</b></li><li>If you need to select a cell, you can use the grid API methods.</li></ul>
}
</div></div></igx-snackbar>html
IgniteUI for Angular Hierarchical Grid component provides three different selection modes - Row selection, Cell selection and Column selection. By default only Multi-cell selection mode is enabled in the Hierarchical Grid. In order to change/enable selection mode you can use rowSelection, cellSelection or selectable properties.
Angular Row Selection
Property rowSelection enables you to specify the following options:
none - Row selection would be disabled for the Hierarchical Grid
single - Selection of only one row within the Hierarchical Grid would be available
multiple - Multi-row selection would be available by using the Row selectors, with a key combination like ctrl + click, or by pressing the space key once a cell is focused
Property cellSelection enables you to specify the following options:
none - Cell selection would be disabled for the Hierarchical Grid
single - Selection of only one cell within the Hierarchical Grid would be available.
multiple - Currently, this is the default state of the selection in the Hierarchical Grid. Multi-cell selection is available by mouse dragging over the cells, after a left button mouse clicked continuously.
Using the Hierarchical Grid with Selection enabled on IE11 requires the explicit import of the array polyfill in polyfill.ts of the angular application. IE11 is no longer supported as of version 13.0.0.
import'core-js/es7/array';
typescript
When the grid has no primaryKey set and remote data scenarios are enabled (when paging, sorting, filtering, scrolling trigger requests to a remote server to retrieve the data to be displayed in the grid), a row will lose the following state after a data request completes: