diff --git a/src/app/components/table/table.ts b/src/app/components/table/table.ts index c5fba8770c2..c65318b4e85 100644 --- a/src/app/components/table/table.ts +++ b/src/app/components/table/table.ts @@ -1577,9 +1577,9 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable this.restoringSort = false; } - this.lazy && this.onLazyLoad.emit(this.createLazyLoadMetadata()); - - if (this.value) { + if (this.lazy) { + this.onLazyLoad.emit(this.createLazyLoadMetadata()); + } else if (this.value) { if (this.customSort) { this.sortFunction.emit({ data: this.value, @@ -1587,7 +1587,7 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable field: field, order: order }); - } else if (!this.lazy) { + } else { this.value.sort((data1, data2) => { let value1 = ObjectUtils.resolveFieldData(data1, field); let value2 = ObjectUtils.resolveFieldData(data2, field); @@ -1605,7 +1605,7 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable this._value = [...this.value]; } - if ((!this.lazy || this.customSort) && this.hasFilter()) { + if (this.hasFilter()) { this._filter(); } } @@ -1627,15 +1627,16 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable } if (this.multiSortMeta) { - this.lazy && this.onLazyLoad.emit(this.createLazyLoadMetadata()); - if (this.value) { + if (this.lazy) { + this.onLazyLoad.emit(this.createLazyLoadMetadata()); + } else if (this.value) { if (this.customSort) { this.sortFunction.emit({ data: this.value, mode: this.sortMode, multiSortMeta: this.multiSortMeta }); - } else if (!this.lazy) { + } else { this.value.sort((data1, data2) => { return this.multisortField(data1, data2, this.multiSortMeta, 0); }); @@ -1643,7 +1644,7 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable this._value = [...this.value]; } - if ((!this.lazy || this.customSort) && this.hasFilter()) { + if (this.hasFilter()) { this._filter(); } }