I'm having a p-dataView (PrimNG) with paging that working fine except for some paging issue. If I page to a page other than 1 and then make a call to the rest api and recieve the data, the dataView is still on the same page instead of setting it to page 1. Seems to me this is not the desired behaviour. I've tried using the [first] property but it did nothing. Here is my code:
<p-button label="getdata" (onClick)="loadData()"></p-button>
<p-dataView [value]="datafromDB" [rows]="pageSize" [totalRecords]='totalRecords'
[paginator]="true" paginatorPosition="bottom" [sortField]="sortColumn" [sortOrder]="sortOrder" [loadingIcon]="loadingIcon" [loading]="loading" [emptyMessage]="">
<p-header>
<div >
headers
</div>
</p-header>
<ng-template let-result pTemplate="listItem">
<div class="list-item">
<div>
content
</div>
</div>
</ng-template>
</p-dataView>
The component code:
loadData()
{
this.setReportRequest();
this.executeReport();
}
setReportRequest()
{
initiate get request
}
executeReport()
{
this.loading = true;
this.subscriptions.push(this.srv.getdata(request).subscribe(result =>
{
this.loading = false;
this.totalRecords = result.data;
this.totalPages = result.TotalPages;
this.datafromDB = this.makeSomeMapping(result.recordset);
}, error =>
{
}));
}