diff --git a/src/components/table/nz-table.component.ts b/src/components/table/nz-table.component.ts index 45dcf579f6..e5fdf95d24 100644 --- a/src/components/table/nz-table.component.ts +++ b/src/components/table/nz-table.component.ts @@ -111,6 +111,7 @@ export class NzTableComponent implements AfterViewInit, OnInit { @Input() nzShowTotal = false; @Input() nzShowFooter = false; @Input() nzShowTitle = false; + @Input() nzIsPageIndexReset = true; @ContentChild('nzFixedHeader') fixedHeader: TemplateRef; @ContentChildren(NzThDirective, { descendants: true }) @@ -201,7 +202,12 @@ export class NzTableComponent implements AfterViewInit, OnInit { if (!this._isAjax) { if (this.nzIsPagination) { if (forceRefresh) { - this.nzPageIndex = 1; + if (this.nzIsPageIndexReset) { + this.nzPageIndex = 1; + } else { + const maxPageIndex = Math.ceil(this._dataSet.length / this.nzPageSize); + this.nzPageIndex = this.nzPageIndex > maxPageIndex ? maxPageIndex : this.nzPageIndex; + } } this.data = this._dataSet.slice((this.nzPageIndex - 1) * this.nzPageSize, this.nzPageIndex * this.nzPageSize); } else { diff --git a/src/showcase/nz-demo-table/nz-demo-table.html b/src/showcase/nz-demo-table/nz-demo-table.html index b6840f74c3..f027d3681a 100644 --- a/src/showcase/nz-demo-table/nz-demo-table.html +++ b/src/showcase/nz-demo-table/nz-demo-table.html @@ -1,4 +1,4 @@ -
+

Table 表格

@@ -290,7 +290,12 @@

nz-table Boolean false - + + nzIsPageIndexReset + 数据变更后是否保留在数据变更前的页码 + Boolean + true +

nz-table-sort