Angular NgPrime turbo表格是否在数据刷新时设置当前页码?

Angular NgPrime turbo表格是否在数据刷新时设置当前页码?,angular,primeng,primeng-turbotable,Angular,Primeng,Primeng Turbotable,在NgPrime turbo表格中,我有编辑功能。在服务器中保存数据后,我将重新加载网格。但是无法保留当前页面。如何将页码设置为网格? 我找到了一种使用此函数获取当前页码的方法 paginate(event) { let pageIndex = event.first/event.rows + 1; } 通过将this属性添加到表标记(onPage)=“paginate($event)”。 如何将页码设置为网格?看起来您可以控制显示的第一行,而不是直接控制页码本身: <p-tabl

在NgPrime turbo表格中,我有编辑功能。在服务器中保存数据后,我将重新加载网格。但是无法保留当前页面。如何将页码设置为网格? 我找到了一种使用此函数获取当前页码的方法

 paginate(event) { 
let pageIndex = event.first/event.rows + 1;
 }
通过将this属性添加到表标记
(onPage)=“paginate($event)”

如何将页码设置为网格?

看起来您可以控制显示的第一行,而不是直接控制页码本身:

<p-table [columns]="cols" [value]="cars" [paginator]="true" [rows]="10" [first]="first">
然后,在组件中:

@ViewChild('myTable') myTable: TurboTable;
    ...
this.myTable.first = desiredFirstRow;

我将借此机会将我的旧表代码更新为TurboTable,我很快就会知道这是否确实有效。

看起来,您可以控制显示的第一行,而不是直接控制页码:

<p-table [columns]="cols" [value]="cars" [paginator]="true" [rows]="10" [first]="first">
然后,在组件中:

@ViewChild('myTable') myTable: TurboTable;
    ...
this.myTable.first = desiredFirstRow;

我将借此机会将我的旧表代码更新为TurboTable,我很快就会知道这是否确实有效。

@kshetline-answer对我有效。
HTML

<p-table #dt [columns]="columnHeaders" [value]="batchList" [lazy]="true" (onLazyLoad)="lazyLoadNextBatch($event)" [paginator]="true" [rows]="recordsPerPageCount?.value" [totalRecords]="totalRecords" [responsive]="true">

打字稿

onRecordsPerPageCountChange() {
    this.totalRecords = 0;
    this.pageNavLinks = 0;
    this.myTable.first = 0; // <-- this did the work.
    this.lazyLoadNextBatch({ 'first': 0 });
}
lazyLoadNextBatch(event: LazyLoadEvent) {
    // calculate the page number from event.first
    this.loading = true;
    const pageNumber = Math.round(event.first / this.recordsPerPageCount.value) + 1;
    this.bmService.getBatchList(this.batchListStatus, pageNumber, this.recordsPerPageCount.value)
        .subscribe(response => {
            this.batchList = response.batches;
            // totalRecords is used to find the navigation links
            this.totalRecords = response.batches[0].TotalRowCount;
            this.pageNavLinks = Math.round(this.totalRecords / this.recordsPerPageCount.value);
            this.loading = false;
        });
}
onRecordsPerPageCountChange(){
this.totalRecords=0;
this.pageNavLinks=0;
this.myTable.first=0;//{
this.batchList=response.batchs;
//totalRecords用于查找导航链接
this.totalRecords=response.batches[0].TotalRowCount;
this.pageNavLinks=Math.round(this.totalRecords/this.recordsPerPageCount.value);
这一点:加载=错误;
});
}

@kshetline答案对我来说确实有用。
HTML

<p-table #dt [columns]="columnHeaders" [value]="batchList" [lazy]="true" (onLazyLoad)="lazyLoadNextBatch($event)" [paginator]="true" [rows]="recordsPerPageCount?.value" [totalRecords]="totalRecords" [responsive]="true">

打字稿

onRecordsPerPageCountChange() {
    this.totalRecords = 0;
    this.pageNavLinks = 0;
    this.myTable.first = 0; // <-- this did the work.
    this.lazyLoadNextBatch({ 'first': 0 });
}
lazyLoadNextBatch(event: LazyLoadEvent) {
    // calculate the page number from event.first
    this.loading = true;
    const pageNumber = Math.round(event.first / this.recordsPerPageCount.value) + 1;
    this.bmService.getBatchList(this.batchListStatus, pageNumber, this.recordsPerPageCount.value)
        .subscribe(response => {
            this.batchList = response.batches;
            // totalRecords is used to find the navigation links
            this.totalRecords = response.batches[0].TotalRowCount;
            this.pageNavLinks = Math.round(this.totalRecords / this.recordsPerPageCount.value);
            this.loading = false;
        });
}
onRecordsPerPageCountChange(){
this.totalRecords=0;
this.pageNavLinks=0;
this.myTable.first=0;//{
this.batchList=response.batchs;
//totalRecords用于查找导航链接
this.totalRecords=response.batches[0].TotalRowCount;
this.pageNavLinks=Math.round(this.totalRecords/this.recordsPerPageCount.value);
这一点:加载=错误;
});
}

此解决方案不适用于我@kshetline,即使将
first
值更改为10,页面也会刷新到first pageI我用一些可能有用的东西更新了上述答案,基于旧的
DataTable
遇到的相反问题——当我真的想让它转到第一个(零)页时,它会刷新到一个旧的页码。即使将
first
值更改为10,此解决方案对我@kshetline也不起作用,页面刷新到第一页我用一些可能有用的东西更新了上面的答案,基于旧的
DataTable
——当我真的想让它转到第一页(zeroeth)时,它会刷新到一个旧的页码。你只需在更新之前再次设置sortOrder属性即可。。它应该可以完成这项工作。您只需在更新之前再次设置sortOrder属性即可。。它应该能完成任务。