Sorting and lazy loading don't work together
Latest version of Angular 2 and PrimeNG. Sorting works until I add lazy loading:
<p-dataTable [value]="cars" selectionMode="single"
[(selection)]="selectedCar" (onRowSelect)="onRowSelect($event)"
[rows]="10" [paginator]="true" [pageLinks]="4" [rowsPerPageOptions]="[5,10,20,50,100]"
[responsive]="true" resizableColumns="true" [lazy]="true"
[totalRecords]="totalRecords" (onLazyLoad)="loadCarsLazy($event)">
<p-column field="idd" header="ID" [sortable]="true">
<template let-idd let-car="rowData" pTemplate="body">
<div [style.background-color]="getStyle(car.idd)">
<span [style.color]="black" >{{car[idd.field]}}</span>
</div>
</template>
</p-column>
<p-column field="vin" header="Vin" [sortable]="true"></p-column>
<p-column field="year" header="Year" [sortable]="true"></p-column>
<p-column field="brand" header="Brand" [sortable]="true"></p-column>
<p-column field="color" header="Color" [sortable]="true"></p-column>
</p-dataTable>
still nothing ? did somebody find a trick to make them work together ?
You do know that in the lazy loading case, the SERVER needs to handle sorting? The dataTable only sends the properties to be sorted on to the server. The docs could be more explicit.
oh ok, that makes sense ! it's obvious. what a dumb I am. Thanks anyway for the help. This issues should be close I think.
@jgiro I hope you find the solution. if not : when lazyloading, the sort value (field and order) are send to the event (onLazyLoad) and not from the (sortFunction) like the usual way.
from the lazyload doc
loadData(event: LazyLoadEvent) {
//event.first = First row offset
//event.rows = Number of rows per page
// ---> event.sortField = Field name to sort in single sort mode
// ---> event.sortOrder = Sort order as number, 1 for asc and -1 for dec in single sort mode
//multiSortMeta: An array of SortMeta objects used in multiple columns sorting. Each SortMeta has field and order properties.
//filters: Filters object having field as key and filter value, filter matchMode as value
this.cars = //do a request to a remote datasource using a service and return the cars that match the lazy load criteria
}
In lazy mode, you should do the sorting at backend.
Sorting is not working with Virtual scroll (Lazy loading) in PrimeNG data table.Actually with large data set ,primeNg table become hang, for this resolution I have implemented Virtual scroll(Lazy loading). But there is a problem that Sorting is not working in lazy load.
Also,I tried custom sorting for that but still not working.Actually my custom sort function is not working with Lazy loading.Any solution ?
Is It fixed in recent PrimeNG release ?
is Lazy Load equivalent to On Demand Load? I am a bit confused about Lazy Load.
Why did you close the incident without any solution. I have same issue and after landing here I saw this. What a great PrimeFace team. Should I create new ticket in list of more than 900 open issues?