Skip to content

Commit

Permalink
fix(grid): use the correct column strategy if sorting via the api #2734
Browse files Browse the repository at this point in the history
  • Loading branch information
hanastasov committed Oct 30, 2018
1 parent e4017ba commit 1fd45cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions projects/igniteui-angular/src/lib/grids/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent> {
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;
}
Expand All @@ -348,6 +348,7 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent> {
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);
}

Expand Down Expand Up @@ -458,7 +459,6 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent> {
}

protected prepare_sorting_expression(stateCollections: Array<Array<any>>, expression: ISortingExpression) {
DataUtil.mergeDefaultProperties(expression, SortingStateDefaults);
if (expression.dir === SortingDirection.None) {
stateCollections.forEach(state => {
state.splice(state.findIndex((expr) => expr.fieldName === expression.fieldName), 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class IgxGridAPIService extends GridBaseAPIService<IgxGridComponent> {
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);
Expand All @@ -23,6 +23,7 @@ export class IgxGridAPIService extends GridBaseAPIService<IgxGridComponent> {
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);
}

Expand Down

0 comments on commit 1fd45cf

Please sign in to comment.