Skip to content

Commit

Permalink
Fix grid pagination, search & sort.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaalha committed Sep 11, 2019
1 parent eb82f3b commit f55cd2d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 3 deletions.
Binary file modified capturas/grid-v2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified capturas/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/app/modules/person/person.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
matSort matSortActive="name" matSortDisableClear matSortDirection="asc">

<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.name }}</mat-cell>
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.first_name + ' ' + row.last_name }}</mat-cell>
</ng-container>

<ng-container matColumnDef="age">
Expand Down
2 changes: 2 additions & 0 deletions src/app/modules/person/person.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ export class PersonComponent implements AfterViewInit {
// GET PERSONS
getData() {
this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);

merge(this.sort.sortChange, this.paginator.page)
.pipe(
startWith({}),
switchMap(() => {
this.isLoading = true;
return this.personService!
.getList(
this.sort.active,
this.sort.direction,
this.pageSize,
this.page,
Expand Down
3 changes: 2 additions & 1 deletion src/app/services/person.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export class PersonService {
'x-access-token': localStorage.getItem('token')
});

getList(order: string, pageSize: number, page: number, search: string) {
getList(sortActive: string, order: string, pageSize: number, page: number, search: string) {
let params = new HttpParams();
params = params.append('active', sortActive);
params = params.append('order', order);
params = params.append('search', search);
params = params.append('pageSize', pageSize.toString());
Expand Down

0 comments on commit f55cd2d

Please sign in to comment.