我有一个 p-dataView (PrimNG) 与分页工作正常,除了一些分页问题。如果我分页到 1 以外的页面,然后调用其余 api 并接收数据,则 dataView 仍然在同一页面上,而不是将其设置为第 1 页。在我看来,这不是所需的行为。我试过使用 [first] 属性,但它什么也没做。这是我的代码:
<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>
组件代码:
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 =>
{
}));
}