Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 0535663

Browse files
Ghislain BeaulacGhislain Beaulac
authored andcommitted
fix(preset): Preset with Sort was not working correctly with GraphQL
1 parent 80bba3e commit 0535663

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/app/modules/angular-slickgrid/services/graphql.service.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,7 @@ export class GraphqlService implements BackendService {
340340
// if user defined some "presets", then we need to find the filters from the column definitions instead
341341
let columnDef: Column | undefined;
342342
if (isUpdatedByPreset && Array.isArray(this._columnDefinitions)) {
343-
columnDef = this._columnDefinitions.find((column: Column) => {
344-
return column.id === columnFilter.columnId;
345-
});
343+
columnDef = this._columnDefinitions.find((column: Column) => column.id === columnFilter.columnId);
346344
} else {
347345
columnDef = columnFilter.columnDef;
348346
}
@@ -447,8 +445,9 @@ export class GraphqlService implements BackendService {
447445

448446
// display the correct sorting icons on the UI, for that it requires (columnId, sortAsc) properties
449447
const tmpSorterArray = currentSorters.map((sorter) => {
448+
const columnDef = this._columnDefinitions.find((column: Column) => column.id === sorter.columnId);
450449
graphqlSorters.push({
451-
field: sorter.columnId + '',
450+
field: (columnDef.queryField || columnDef.queryFieldSorter || columnDef.field || columnDef.id) + '',
452451
direction: sorter.direction
453452
});
454453
return {
@@ -468,7 +467,7 @@ export class GraphqlService implements BackendService {
468467
for (const column of sortColumns) {
469468
if (column && column.sortCol) {
470469
currentSorters.push({
471-
columnId: (column.sortCol.field || column.sortCol.id) + '',
470+
columnId: column.sortCol.id + '',
472471
direction: column.sortAsc ? SortDirection.ASC : SortDirection.DESC
473472
});
474473

0 commit comments

Comments
 (0)