From 286aa561fd565e77b670b20105a3b0e9144f55de Mon Sep 17 00:00:00 2001 From: Vildan Softic Date: Wed, 17 Apr 2024 23:43:06 +0200 Subject: [PATCH 1/2] fix: odata sorting column id instead of field --- .../src/services/__tests__/grid-odata.service.spec.ts | 10 +++++----- packages/odata/src/services/grid-odata.service.ts | 10 ++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/odata/src/services/__tests__/grid-odata.service.spec.ts b/packages/odata/src/services/__tests__/grid-odata.service.spec.ts index a9e446a11..6c135a35c 100644 --- a/packages/odata/src/services/__tests__/grid-odata.service.spec.ts +++ b/packages/odata/src/services/__tests__/grid-odata.service.spec.ts @@ -1444,7 +1444,7 @@ describe('GridOdataService', () => { const currentSorters = service.getCurrentSorters(); expect(query).toBe(expectation); - expect(currentSorters).toEqual([{ columnId: 'Gender', direction: 'desc' }, { columnId: 'FirstName', direction: 'asc' }]); + expect(currentSorters).toEqual([{ columnId: 'gender', direction: 'desc' }, { columnId: 'firstName', direction: 'asc' }]); }); it('should return a query string using a different field to query when the column has a "queryField" defined in its definition', () => { @@ -1460,7 +1460,7 @@ describe('GridOdataService', () => { const currentSorters = service.getCurrentSorters(); expect(query).toBe(expectation); - expect(currentSorters).toEqual([{ columnId: 'Gender', direction: 'desc' }, { columnId: 'Name', direction: 'asc' }]); + expect(currentSorters).toEqual([{ columnId: 'gender', direction: 'desc' }, { columnId: 'name', direction: 'asc' }]); }); it('should return a query string using a different field to query when the column has a "queryFieldSorter" defined in its definition', () => { @@ -1476,7 +1476,7 @@ describe('GridOdataService', () => { const currentSorters = service.getCurrentSorters(); expect(query).toBe(expectation); - expect(currentSorters).toEqual([{ columnId: 'Gender', direction: 'desc' }, { columnId: 'Name', direction: 'asc' }]); + expect(currentSorters).toEqual([{ columnId: 'gender', direction: 'desc' }, { columnId: 'name', direction: 'asc' }]); }); it('should return a query without the field sorter when its field property is missing', () => { @@ -1492,7 +1492,7 @@ describe('GridOdataService', () => { const currentSorters = service.getCurrentSorters(); expect(query).toBe(expectation); - expect(currentSorters).toEqual([{ columnId: 'Gender', direction: 'desc' }, { columnId: 'FirstName', direction: 'asc' }]); + expect(currentSorters).toEqual([{ columnId: 'gender', direction: 'desc' }, { columnId: 'firstName', direction: 'asc' }]); }); it('should return a query without any sorting after clearSorters was called', () => { @@ -1546,7 +1546,7 @@ describe('GridOdataService', () => { const currentSorters = service.getCurrentSorters(); expect(query).toBe(expectation); - expect(currentSorters).toEqual([{ columnId: 'Gender', direction: 'desc' }, { columnId: 'FirstName', direction: 'asc' }]); + expect(currentSorters).toEqual([{ columnId: 'gender', direction: 'desc' }, { columnId: 'firstName', direction: 'asc' }]); }); it('should return a query without any sorting after clearSorters was called but without pagination when "enablePagination" is set to False', () => { diff --git a/packages/odata/src/services/grid-odata.service.ts b/packages/odata/src/services/grid-odata.service.ts index 4af5d1377..f54cace12 100644 --- a/packages/odata/src/services/grid-odata.service.ts +++ b/packages/odata/src/services/grid-odata.service.ts @@ -543,12 +543,10 @@ export class GridOdataService implements BackendService { queryField = titleCase(queryField); } - if (columnFieldName !== '') { - currentSorters.push({ - columnId: columnFieldName, - direction: columnDef.sortAsc ? 'asc' : 'desc' - }); - } + currentSorters.push({ + columnId: columnDef.sortCol.id, + direction: columnDef.sortAsc ? SortDirection.asc : SortDirection.desc + }); if (queryField !== '') { odataSorters.push({ From de33b8dc31560a51e60c98b3b32c34ab645dbb16 Mon Sep 17 00:00:00 2001 From: Vildan Softic Date: Wed, 17 Apr 2024 23:43:38 +0200 Subject: [PATCH 2/2] test: update example09 with persistance and add cy test --- .../src/examples/example09.html | 4 +++ .../src/examples/example09.ts | 17 +++++++---- test/cypress/e2e/example09.cy.ts | 29 +++++++++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/examples/vite-demo-vanilla-bundle/src/examples/example09.html b/examples/vite-demo-vanilla-bundle/src/examples/example09.html index 952839de5..783e87ef6 100644 --- a/examples/vite-demo-vanilla-bundle/src/examples/example09.html +++ b/examples/vite-demo-vanilla-bundle/src/examples/example09.html @@ -15,6 +15,7 @@
error and its only purpose is to demo what would happen when you encounter a backend server error (the UI should rollback to previous state before you did the action). Also changing Page Size to 50,000 will also throw which again is for demo purposes. + Moreover, the example will persist changes in the local storage, so if you refresh the page, it will remember your last settings.
@@ -29,6 +30,9 @@
+