Adds pagination functionality on DMP listing.
This commit is contained in:
parent
e387ed152c
commit
df12702499
|
@ -21,7 +21,7 @@
|
||||||
<div class="row" *ngFor="let item of listingItems; let i = index">
|
<div class="row" *ngFor="let item of listingItems; let i = index">
|
||||||
<app-dmp-listing-item-component class="col-12" [showDivider]="i != (listingItems.length - 1)" [dmp]="item" (onClick)="rowClicked($event)"></app-dmp-listing-item-component>
|
<app-dmp-listing-item-component class="col-12" [showDivider]="i != (listingItems.length - 1)" [dmp]="item" (onClick)="rowClicked($event)"></app-dmp-listing-item-component>
|
||||||
</div>
|
</div>
|
||||||
<mat-paginator #paginator [length]="totalCount" [pageSizeOptions]="[10, 25, 100]"></mat-paginator>
|
<mat-paginator #paginator [length]="totalCount" [pageSizeOptions]="[10, 25, 100]" (page)="pageThisEvent($event)"></mat-paginator>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -89,6 +89,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
|
if (this._paginator.pageSize === undefined) this._paginator.pageSize = 10;
|
||||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||||
let fields: Array<string> = new Array();
|
let fields: Array<string> = new Array();
|
||||||
if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; }
|
if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; }
|
||||||
|
@ -113,6 +114,11 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pageThisEvent(event) {
|
||||||
|
console.log(event);
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
rowClicked(dmp: DmpListingModel) {
|
rowClicked(dmp: DmpListingModel) {
|
||||||
this.router.navigate(['/plans/edit/' + dmp.id]);
|
this.router.navigate(['/plans/edit/' + dmp.id]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue