diff --git a/src/app/components/paginator/paginator.ts b/src/app/components/paginator/paginator.ts index 97a7550fccd..28999d65133 100755 --- a/src/app/components/paginator/paginator.ts +++ b/src/app/components/paginator/paginator.ts @@ -378,7 +378,6 @@ export class Paginator implements OnInit, AfterContentInit, OnChanges { this.updatePageLinks(); this.updatePaginatorState(); this.updateFirst(); - this.updateRowsPerPageOptions(); } if (simpleChange.first) { @@ -406,7 +405,7 @@ export class Paginator implements OnInit, AfterContentInit, OnChanges { this.rowsPerPageItems = []; for (let opt of this.rowsPerPageOptions) { if (typeof opt == 'object' && opt['showAll']) { - this.rowsPerPageItems.unshift({ label: opt['showAll'], value: this.totalRecords }); + this.rowsPerPageItems.unshift({ label: opt['showAll'], value: -1 }); } else { this.rowsPerPageItems.push({ label: String(this.getLocalization(opt)), value: opt }); } @@ -423,7 +422,7 @@ export class Paginator implements OnInit, AfterContentInit, OnChanges { } getPageCount(): number { - return Math.ceil(this.totalRecords / this.rows); + return this.rows > 0 ? Math.ceil(this.totalRecords / this.rows) : 1; } calculatePageLinkBoundaries(): [number, number] { @@ -463,7 +462,7 @@ export class Paginator implements OnInit, AfterContentInit, OnChanges { var pc = this.getPageCount(); if (p >= 0 && p < pc) { - this._first = this.rows * p; + this._first = this.rows > 0 ? this.rows * p : 0; var state = { page: p, first: this.first, @@ -485,7 +484,7 @@ export class Paginator implements OnInit, AfterContentInit, OnChanges { } getPage(): number { - return Math.floor(this.first / this.rows); + return this.rows > 0 ? Math.floor(this.first / this.rows) : 0; } changePageToFirst(event: Event): void { @@ -550,8 +549,8 @@ export class Paginator implements OnInit, AfterContentInit, OnChanges { .replace('{currentPage}', String(this.currentPage())) .replace('{totalPages}', String(this.getPageCount())) .replace('{first}', String(this.totalRecords > 0 ? this._first + 1 : 0)) - .replace('{last}', String(Math.min(this._first + this.rows, this.totalRecords))) - .replace('{rows}', String(this.rows)) + .replace('{last}', String(Math.min(this._first + (this.rows > 0 ? this.rows : this.totalRecords), this.totalRecords))) + .replace('{rows}', String(this.rows > 0 ? this.rows : this.totalRecords)) .replace('{totalRecords}', String(this.totalRecords)); } } diff --git a/src/app/components/table/table.ts b/src/app/components/table/table.ts index 266c5063996..1393b2e178a 100644 --- a/src/app/components/table/table.ts +++ b/src/app/components/table/table.ts @@ -1463,7 +1463,7 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable dataToRender(data: any) { const _data = data || this.processedData; - if (_data && this.paginator) { + if (_data && this.paginator && this.rows > 0) { const first = this.lazy ? 0 : this.first; return _data.slice(first, first + this.rows); }