Lazy DataTable recursive LazyLoadEvent
I'm submitting [x] bug report => Search github for a similar issue or PR before submitting [ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap [ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Current behavior The DataTable is declared in html as
[value]="rows"
[lazy]="true"
(onLazyLoad)="loadPageLazy($event)"
[totalRecords]="totalRecords"
The component.ts is implemented as:
loadPageLazy(event: LazyLoadEvent) {
this.gridService.getPage(JSON.stringify(event)).subscribe((result: any) => {
this.rows = result.rows;
this.totalRecords = result.totalRecords;
});
}
The function loadPageLazy() is called recursively/endlessly if some particular filters are specified in UI, for example, not null combobox filter value with non-empty page rows result.
Workaround solution Implement function loadPageLazy() with validation for duplicate identical reloads
jsonLazyLoadEventLast: string;
loadPageLazy(event: LazyLoadEvent) {
let jsonLazyLoadEvent = JSON.stringify(event);
if (this.jsonLazyLoadEventLast === jsonLazyLoadEvent) {
return;
}
this.jsonLazyLoadEventLast = jsonLazyLoadEvent;
this.gridService.getPage(jsonLazyLoadEvent)).subscribe((result: any) => {
this.rows = result.rows;
this.totalRecords = result.totalRecords;
});
}
Expected behavior LazyLoadEvent should be triggered once without recursions for any filters and result page rows.
Please tell us about your environment: PrimeNG 2.1.1 Angular 2.4.0 Browser: Chrome 56.0.2924.87
I have the same problem, when I filter for something, it is recursively calling my (onLazyLoad) function. It seems to be the same problem like #1434 and #1502
My enviroment is: PrimeNG 4.0.0-rc.2 Angular 4.0.1
Also happens with: PrimeNG 4.0.0-rc.3 Angular 4.0.1
Can confirm that this happens with: PrimeNG 4.0.0-rc.3 Angular 4.0.1
Thank you @gorokhmn, your fix works for me
The issue seems to be resolved in PrimeNG 4.0.3 + Angular 4.1.3
This should be fixed in recent PrimeNG release, please try with it and if the issue persists drop a comment with along with a test case based on plunkr below and we'll review again.
http://plnkr.co/edit/Wj39h1?p=preview