Skip to content

Commit

Permalink
Merge pull request #16235 from primefaces/issue-16182
Browse files Browse the repository at this point in the history
Fixed #16182 - p-table triggers lazy loading event twice
  • Loading branch information
cetincakiroglu authored Aug 15, 2024
2 parents d2756f9 + f64aba8 commit 8a0f70b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1577,17 +1577,17 @@ 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,
mode: this.sortMode,
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);
Expand All @@ -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();
}
}
Expand All @@ -1627,23 +1627,24 @@ 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, <SortMeta[]>this.multiSortMeta, 0);
});

this._value = [...this.value];
}

if ((!this.lazy || this.customSort) && this.hasFilter()) {
if (this.hasFilter()) {
this._filter();
}
}
Expand Down

0 comments on commit 8a0f70b

Please sign in to comment.