primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Lazy Datatable sorting issues

Open gorokhmn opened this issue 9 years ago • 1 comments

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

The implementation The DataTable is declared in html as

[value]="rows"
[lazy]="true"
(onLazyLoad)="loadPageLazy($event)"
[totalRecords]="totalRecords"
sortMode="multiple"

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;
  });
}

Below are JSON requests for LazyLoadEvent on UI actions - actual vs. expected

Original page load Actual: {"first":0,"rows":10,"sortOrder":1,"filters":{}} Expected: {"first":0,"rows":10,"filters":{}} ERROR: the entry "sortOrder":1 is redundant

Test 1

UI click-1 sort ID column Actual: {"first":0,"rows":10,"sortField":"id","sortOrder":1,"filters":{}} This is correct JSON for ASC sorting

UI click-2 sort ID column Actual: {"first":0,"rows":10,"sortField":"id","sortOrder":-1,"filters":{}} This is correct JSON for DESC sorting

UI click-3 sort ID column Actual: {"first":0,"rows":10,"sortField":"id","sortOrder":1,"filters":{}} Expected: {"first":0,"rows":10,"filters":{}} ERROR: the entries "sortField":"id","sortOrder":1 are wrong, expected no sorting.

Test 2

Sorting headers in UI are not updated in the above Test-1 This is reported in #1651

Test 3

Multiple columns sorting does not work The table is declared with sortMode="multiple"

UI click-1 sort ID column Actual: {"first":0,"rows":10,"sortField":"id","sortOrder":1,"filters":{}} This is correct JSON for ASC sorting

UI click-2 sort NAME column Actual: {"first":0,"rows":10,"sortField":"name","sortOrder":1,"filters":{}} ERROR: the second sorting on NAME column replaces first ID column sort Expected multiple columns sorting: ID-column + NAME-column.

Please tell us about your environment: PrimeNG 4.1.1 Angular 2.4.0 Browser: Chrome 56.0.2924.87

gorokhmn avatar Feb 10 '17 16:02 gorokhmn

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

cagataycivici avatar Jun 20 '17 12:06 cagataycivici