Last active
July 29, 2022 05:12
-
-
Save pavankjadda/161fca7fe179b1c0369bcb98357edf76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Maps Employees to mat-table data format | |
* | |
* @author Pavan Kumar Jadda | |
* @since 1.0.0 | |
*/ | |
private mapTableData(data: UserData[]) { | |
this.dataSource = new MatTableDataSource<UserData>(data); | |
if (this.optionalParamsPresent()) { | |
this.sort.active = | |
this.route.snapshot.queryParamMap.get('sortBy') ?? 'id'; | |
//@ts-ignore | |
this.sort.direction = | |
this.route.snapshot.queryParamMap.get('sortDirection') ?? 'desc'; | |
this.paginator.pageIndex = | |
Number.parseInt( | |
this.route.snapshot.queryParamMap.get('pageIndex') as string, | |
10 | |
) ?? 0; | |
this.paginator.pageSize = | |
Number.parseInt( | |
this.route.snapshot.queryParamMap.get('pageSize') as string, | |
10 | |
) ?? 10; | |
this.searchTextControl.patchValue( | |
this.route.snapshot.queryParamMap.get('searchText') ?? '' | |
); | |
this.dataSource.filter = | |
this.route.snapshot.queryParamMap.get('searchText') ?? ''; | |
this.dataSource.sort = this.sort; | |
this.dataSource.paginator = this.paginator; | |
this.cdr.detectChanges(); | |
} else { | |
this.dataSource.sort = this.sort; | |
this.dataSource.paginator = this.paginator; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment