From 1fd45cf1498687e4814bbfe60c7a1478a6077b87 Mon Sep 17 00:00:00 2001 From: Hristo Anastasov Date: Tue, 30 Oct 2018 11:32:10 +0200 Subject: [PATCH] fix(grid): use the correct column strategy if sorting via the api #2734 --- projects/igniteui-angular/src/lib/grids/api.service.ts | 4 ++-- .../igniteui-angular/src/lib/grids/grid/grid-api.service.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/igniteui-angular/src/lib/grids/api.service.ts b/projects/igniteui-angular/src/lib/grids/api.service.ts index 2b82fc97bf6..f8caf822045 100644 --- a/projects/igniteui-angular/src/lib/grids/api.service.ts +++ b/projects/igniteui-angular/src/lib/grids/api.service.ts @@ -336,7 +336,7 @@ export class GridBaseAPIService { this.remove_grouping_expression(id, fieldName); } const sortingState = cloneArray(this.get(id).sortingExpressions); - + strategy = strategy ? strategy : this.get_column_by_name(this.get(id).id, fieldName).sortStrategy; this.prepare_sorting_expression([sortingState], { fieldName, dir, ignoreCase, strategy }); this.get(id).sortingExpressions = sortingState; } @@ -348,6 +348,7 @@ export class GridBaseAPIService { if (each.dir === SortingDirection.None) { this.remove_grouping_expression(id, each.fieldName); } + each.strategy = each.strategy ? each.strategy : this.get_column_by_name(this.get(id).id, each.fieldName).sortStrategy; this.prepare_sorting_expression([sortingState], each); } @@ -458,7 +459,6 @@ export class GridBaseAPIService { } protected prepare_sorting_expression(stateCollections: Array>, expression: ISortingExpression) { - DataUtil.mergeDefaultProperties(expression, SortingStateDefaults); if (expression.dir === SortingDirection.None) { stateCollections.forEach(state => { state.splice(state.findIndex((expr) => expr.fieldName === expression.fieldName), 1); diff --git a/projects/igniteui-angular/src/lib/grids/grid/grid-api.service.ts b/projects/igniteui-angular/src/lib/grids/grid/grid-api.service.ts index c15bf491756..d2e4f97f41f 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/grid-api.service.ts +++ b/projects/igniteui-angular/src/lib/grids/grid/grid-api.service.ts @@ -12,7 +12,7 @@ export class IgxGridAPIService extends GridBaseAPIService { public groupBy(id: string, fieldName: string, dir: SortingDirection, ignoreCase: boolean, strategy: ISortingStrategy): void { const groupingState = cloneArray(this.get(id).groupingExpressions); const sortingState = cloneArray(this.get(id).sortingExpressions); - + strategy = strategy ? strategy : this.get_column_by_name(this.get(id).id, fieldName).sortStrategy; this.prepare_sorting_expression([sortingState, groupingState], { fieldName, dir, ignoreCase, strategy }); this.get(id).groupingExpressions = groupingState; this.arrange_sorting_expressions(id); @@ -23,6 +23,7 @@ export class IgxGridAPIService extends GridBaseAPIService { const sortingState = cloneArray(this.get(id).sortingExpressions); for (const each of expressions) { + each.strategy = each.strategy ? each.strategy : this.get_column_by_name(this.get(id).id, each.fieldName).sortStrategy; this.prepare_sorting_expression([sortingState, groupingState], each); }