Skip to content

Commit 26536df

Browse files
committed
Updating the use of rowSelectionChanging event in the sample - refactor
1 parent 0a69e34 commit 26536df

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@
4949
</igx-grid>
5050
</div>
5151

52+
<igx-snackbar #snackbarRowCount (clicked)="snackbar.close()">
53+
<div class="snackBarRowSelection"> <p>Number of selected rows: {{selectedRowsCount}}</p>
54+
</div>
55+
</igx-snackbar>
56+
5257
<igx-snackbar #snackbar actionText="Got it. Thanks!" (clicked)="snackbar.close()">
5358
<div class="container">
5459
<igx-icon>notification_important</igx-icon>
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">
60+
<ng-container *ngIf="selectionMode === 'multiple'">
5961
<ul>
6062
<li><b>Now you can select multiple rows within a grid.</b></li>
6163
<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.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,8 @@ ul {
5858
margin: 20px;
5959
}
6060
}
61+
62+
.snackBarRowSelection{
63+
text-align: center;
64+
padding-bottom: 10px;
65+
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import { FinancialDataService } from '../../services/financial.service';
1515

1616
export class GridSelectionSampleComponent implements OnInit {
1717
@ViewChild('grid1', { static: true }) public grid1: IgxGridComponent;
18-
@ViewChild(IgxSnackbarComponent, { static: true }) public snackbar: IgxSnackbarComponent;
18+
@ViewChild('snackbarRowCount', { static: true }) public snackbarRowCount: IgxSnackbarComponent;
19+
@ViewChild('snackbar', { static: true }) public snackbar: IgxSnackbarComponent;
20+
//@ViewChild(IgxSnackbarComponent, { static: true }) public snackbar: IgxSnackbarComponent;
1921
public data: Observable<any[]>;
2022
public selectionMode = 'multiple';
2123
public selectionModes = [];
@@ -34,8 +36,10 @@ export class GridSelectionSampleComponent implements OnInit {
3436

3537
}
3638
public ngOnInit(): void {
37-
this.snackbar.autoHide = true;
39+
this.snackbar.autoHide = false;
3840
this.snackbar.open();
41+
this.snackbarRowCount.autoHide = true;
42+
this.snackbarRowCount.close();
3943
}
4044
public formatNumber(value: number) {
4145
return value.toFixed(2);
@@ -45,12 +49,14 @@ export class GridSelectionSampleComponent implements OnInit {
4549
}
4650
public handleRowSelection(event:IRowSelectionEventArgs) {
4751
this.selectedRowsCount = event.newSelection.length;
48-
this.snackbar.open();
52+
this.snackbarRowCount.open();
53+
this.snackbar.close();
4954
}
5055

5156
public selectCellSelectionMode(args) {
5257
this.selectionMode = this.selectionModes[args.index].label;
5358
this.snackbar.open();
59+
this.snackbarRowCount.close();
5460
this.selectedRowsCount = undefined;
5561
}
5662
}

0 commit comments

Comments
 (0)