1- import { Component , OnInit , ViewChild } from '@angular/core' ;
2- import { IgxSnackbarComponent } from 'igniteui-angular' ;
1+ import { Component , OnDestroy , OnInit , ViewChild } from '@angular/core' ;
2+ import { IgxSnackbarComponent , IRowSelectionEventArgs } from 'igniteui-angular' ;
33import { SINGERS } from '../../data/singersData' ;
44
55@Component ( {
@@ -8,7 +8,7 @@ import { SINGERS } from '../../data/singersData';
88 templateUrl : 'hierarchical-grid-selection.component.html'
99} )
1010
11- export class HGridSelectionSampleComponent implements OnInit {
11+ export class HGridSelectionSampleComponent implements OnInit , OnDestroy {
1212 @ViewChild ( 'snackbarRowCount' , { static : true } ) public snackbarRowCount : IgxSnackbarComponent ;
1313 @ViewChild ( 'snackbar' , { static : true } ) public snackbar : IgxSnackbarComponent ;
1414 public localdata ;
@@ -31,6 +31,10 @@ export class HGridSelectionSampleComponent implements OnInit {
3131 this . snackbar . open ( ) ;
3232 }
3333
34+ public ngOnDestroy ( ) : void {
35+ this . snackbar . close ( ) ;
36+ }
37+
3438 public selectCellSelectionMode ( args ) {
3539 this . selectionMode = this . selectionModes [ args . index ] . label ;
3640 this . snackbarRowCount . close ( ) ;
@@ -39,9 +43,9 @@ export class HGridSelectionSampleComponent implements OnInit {
3943 this . selectedRowIndex = undefined ;
4044 }
4145
42- public handleRowSelection ( event ) {
46+ public handleRowSelection ( event : IRowSelectionEventArgs ) {
4347 this . selectedRowsCount = event . newSelection . length ;
44- if ( event . newSelection . length > 0 ) {
48+ if ( event . newSelection . length > 0 ) {
4549 this . selectedRowIndex = event . newSelection [ 0 ] . ID ;
4650 }
4751 else this . selectedRowIndex = undefined ;
@@ -50,4 +54,5 @@ export class HGridSelectionSampleComponent implements OnInit {
5054 }
5155
5256 public formatter = ( a ) => a ;
57+
5358}
0 commit comments