Skip to content

Commit

Permalink
fix(preset): Preset with backend were not working when using queryField
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Mar 30, 2018
1 parent 36ea506 commit 7ce538a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,7 @@ export class GraphqlService implements BackendService {
// if user defined some "presets", then we need to find the filters from the column definitions instead
let columnDef: Column | undefined;
if (isUpdatedByPreset && Array.isArray(this._columnDefinitions)) {
columnDef = this._columnDefinitions.find((column: Column) => {
return column.id === columnFilter.columnId;
});
columnDef = this._columnDefinitions.find((column: Column) => column.id === columnFilter.columnId);
} else {
columnDef = columnFilter.columnDef;
}
Expand Down Expand Up @@ -452,8 +450,9 @@ export class GraphqlService implements BackendService {

// display the correct sorting icons on the UI, for that it requires (columnId, sortAsc) properties
const tmpSorterArray = currentSorters.map((sorter) => {
const columnDef = this._columnDefinitions.find((column: Column) => column.id === sorter.columnId);
graphqlSorters.push({
field: sorter.columnId + '',
field: (columnDef.queryField || columnDef.queryFieldSorter || columnDef.field || columnDef.id) + '',
direction: sorter.direction
});
return {
Expand All @@ -467,13 +466,13 @@ export class GraphqlService implements BackendService {
// orderBy:[{field: lastName, direction: ASC}, {field: firstName, direction: DESC}]
if (sortColumns && sortColumns.length === 0) {
graphqlSorters = new Array(this.defaultOrderBy); // when empty, use the default sort
currentSorters = new Array({ columnId: this.defaultOrderBy.direction, direction: this.defaultOrderBy.direction });
currentSorters = new Array({ columnId: this.defaultOrderBy.field, direction: this.defaultOrderBy.direction });
} else {
if (sortColumns) {
for (const column of sortColumns) {
if (column && column.sortCol) {
currentSorters.push({
columnId: (column.sortCol.queryField || column.sortCol.queryFieldSorter || column.sortCol.field || column.sortCol.id) + '',
columnId: column.sortCol.id + '',
direction: column.sortAsc ? SortDirection.ASC : SortDirection.DESC
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,14 @@ export class GridOdataService implements BackendService {
for (const column of sortColumns) {
if (column.sortCol) {
let fieldName = (column.sortCol.queryField || column.sortCol.queryFieldSorter || column.sortCol.field || column.sortCol.id) + '';
let columnFieldName = (column.sortCol.field || column.sortCol.id) + '';
if (this.odataService.options.caseType === CaseType.pascalCase) {
fieldName = String.titleCase(fieldName);
columnFieldName = String.titleCase(columnFieldName);
}

sorterArray.push({
columnId: fieldName,
columnId: columnFieldName,
direction: column.sortAsc ? 'asc' : 'desc'
});
}
Expand Down

0 comments on commit 7ce538a

Please sign in to comment.