lazyload event getting triggered multiple times after the use of [virtual Scroll]="true"

UI Components for Angular
Post Reply
Jisha_jj
Posts: 1
Joined: 30 Nov 2021, 09:00

30 Nov 2021, 09:36

<p-table id="scheGrid" #dt [value]="DetailsList" [columns]="defaultTable.columns.selected"
[(selection)]="selectedDetail" [rowHover]="true"
[filterDelay]="0" editMode="row" sortMode="multiple" [multiSortMeta]="defaultSortCols"
[scrollable]="true" [frozenColumns]="frozenCols" [lazy]="true"
(onLazyLoad)="lazyLoadEvent($event)" [lazyLoadOnInit]="false"
[autoLayout]="true"
[rows]="50"
frozenWidth="90px" scrollHeight="350px"
[virtualScroll]="true"
[virtualRowHeight]="34"
selectionMode="multiple"
metaKeySelection="true"
[reorderableColumns]="true"
dataKey="productionKey"
[loading] = "loading"
stateStorage="session" [totalRecords]="totalRecords"
stateKey="{{stateKey}}">

lazyLoadEvent($event) {
this.typingInterval = setTimeout(()=>{
this.searchModel.Filters = $event.filters;
let pageNumber=$event.first/$event.rows+1;
this.searchModel.SortField = $event.sortField;
this.searchModel.SortOrder = $event.sortOrder;
this.searchDetails(); // server call
}, this.doneTypingTimeout);
}
searchDetails(){
this.service.getDetails(this.serviceUrl, this.searchModel).subscribe(res=>{
this.DetailsList = res.Details;
this.totalRecords = res.totalRecords;
if(!FromDependentPage){
this.selectedDetail = res[0];
}else{
//logic to get table session and assign previously selected record
}
})
}
in this particular grid we actually need multiple sorting ,selection , virtual Scrolling and the grid have some frozen column too.. unable to maintain the selection and get first page record due to unwanted lazy trigger. second page record is visible to the grid during initial load.

Angualr version 10
prime ng "primeng": "^10.0.3"
please support to fix this

Mc128k
Posts: 10
Joined: 08 Jan 2018, 00:21

05 Jul 2022, 17:12

This issue is causing problems to me too. Even if I set lazyLoadOnInit to false, there's a spurious event fired from onScrollIndexChange with the wrong number of items. Happening with 12.2.5 LTS.

Workaround: [lazyLoadOnInit]="false" [virtualScroll]="ready" and set the variable to true only when you have everything necessary to allow the list to fire lazy loading events

Also it seems that with v14 they re-implemented it, possibly fixing this

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests