I have p-table
<p-table [value]="items" [responsive]="true" [pageLinks]="3" [rows]="rows" [lazy]="true" (onLazyLoad)="loadItems($event)" [paginator]="true" [totalRecords]="totalRecords" selectionMode="single" [(selection)]="selectedItem" sortMode="single">
loadItems Function requests sometimes once, when loading a component, and sometimes an infinite number of times. With what it can be connected?
loadItems(event: LazyLoadEvent) {
this.lastLazyLoadEvent = event;
this.loading = true;
const sortOrder: string = event.sortOrder > 0 ? 'asc' : 'desc';
const sortField: string = event.sortField || 'id';
const sorting: string = event.sortField ? sortField + ' ' + sortOrder : null;
}
I'm trying to debug, but I don't understand what the problem could be
whenever you make the changes(filter, sort) on the table (onLazyLoad) event will be called. this is the feature of the table lazyload.
If you call any API call inside the onLazyLoad function set some old and new value condition check. it will prevent multiple API calls