Skip to content

Commit 0a69e34

Browse files
committed
fix(grid-selection):Updating the use of rowSelectionChanging event in the sample
1 parent 4449266 commit 0a69e34

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/app/grid/grid-sample-selection/grid-selection.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@
5252
<igx-snackbar #snackbar actionText="Got it. Thanks!" (clicked)="snackbar.close()">
5353
<div class="container">
5454
<igx-icon>notification_important</igx-icon>
55-
<ng-container *ngIf="selectionMode === 'multiple'">
55+
<ng-container *ngIf="selectionMode === 'multiple' && selectedRowsCount!==undefined">
56+
<p>Number of rows selected: {{selectedRowsCount}}</p>
57+
</ng-container>
58+
<ng-container *ngIf="selectionMode === 'multiple' && selectedRowsCount===undefined">
5659
<ul>
5760
<li><b>Now you can select multiple rows within a grid.</b></li>
5861
<li>Click on row selector field or press SPACE key when some cell is active to toggle row

src/app/grid/grid-sample-selection/grid-selection.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, OnInit, ViewChild } from '@angular/core';
22

3-
import { IgxGridComponent, IgxSnackbarComponent } from 'igniteui-angular';
3+
import { IgxGridComponent, IgxSnackbarComponent, IRowSelectionEventArgs } from 'igniteui-angular';
44
import { Observable } from 'rxjs';
55
import { FinancialDataService } from '../../services/financial.service';
66

@@ -21,6 +21,7 @@ export class GridSelectionSampleComponent implements OnInit {
2121
public selectionModes = [];
2222
public hideRowSelectors = false;
2323
public selectedRows = [1, 2, 3];
24+
public selectedRowsCount;
2425

2526
constructor(private localService: FinancialDataService) {
2627
this.localService.getData(100000);
@@ -33,22 +34,23 @@ export class GridSelectionSampleComponent implements OnInit {
3334

3435
}
3536
public ngOnInit(): void {
36-
this.snackbar.autoHide = false;
37+
this.snackbar.autoHide = true;
3738
this.snackbar.open();
3839
}
39-
4040
public formatNumber(value: number) {
4141
return value.toFixed(2);
4242
}
4343
public formatCurrency(value: number) {
4444
return '$' + value.toFixed(2);
4545
}
46-
public handleRowSelection(event) {
47-
const targetCell = event.cell;
46+
public handleRowSelection(event:IRowSelectionEventArgs) {
47+
this.selectedRowsCount = event.newSelection.length;
48+
this.snackbar.open();
4849
}
4950

5051
public selectCellSelectionMode(args) {
5152
this.selectionMode = this.selectionModes[args.index].label;
5253
this.snackbar.open();
54+
this.selectedRowsCount = undefined;
5355
}
5456
}

0 commit comments

Comments
 (0)