Skip to content

Commit

Permalink
fix(grid): make the getSortStrategyPerColumn method generic #2734
Browse files Browse the repository at this point in the history
  • Loading branch information
hanastasov committed Oct 31, 2018
1 parent 4f9b35d commit cb6eefd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions projects/igniteui-angular/src/lib/grids/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent> {
this.remove_grouping_expression(id, fieldName);
}
const sortingState = cloneArray(this.get(id).sortingExpressions);
strategy = this.getSortStrategyPerColumn(id, fieldName, strategy);
strategy = strategy ? strategy : this.getSortStrategyPerColumn(id, fieldName);
this.prepare_sorting_expression([sortingState], { fieldName, dir, ignoreCase, strategy });
this.get(id).sortingExpressions = sortingState;
}
Expand All @@ -347,7 +347,7 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent> {
if (each.dir === SortingDirection.None) {
this.remove_grouping_expression(id, each.fieldName);
}
each.strategy = this.getSortStrategyPerColumn(id, each.fieldName, each.strategy);
each.strategy = each.strategy ? each.strategy : this.getSortStrategyPerColumn(id, each.fieldName);
this.prepare_sorting_expression([sortingState], each);
}

Expand Down Expand Up @@ -497,10 +497,8 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent> {
protected remove_grouping_expression(id, fieldName) {
}

protected getSortStrategyPerColumn(id: string, fieldName: string, strategy) {
const columnSortStrategy = this.get_column_by_name(this.get(id).id, fieldName) ?
protected getSortStrategyPerColumn(id: string, fieldName: string) {
return this.get_column_by_name(this.get(id).id, fieldName) ?
this.get_column_by_name(id, fieldName).sortStrategy : undefined;
strategy = strategy ? strategy : columnSortStrategy;
return strategy;
}
}
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 = this.getSortStrategyPerColumn(id, fieldName, strategy);
strategy = strategy ? strategy : this.getSortStrategyPerColumn(id, fieldName);
this.prepare_sorting_expression([sortingState, groupingState], { fieldName, dir, ignoreCase, strategy });
this.get(id).groupingExpressions = groupingState;
this.arrange_sorting_expressions(id);
Expand All @@ -23,7 +23,7 @@ export class IgxGridAPIService extends GridBaseAPIService<IgxGridComponent> {
const sortingState = cloneArray(this.get(id).sortingExpressions);

for (const each of expressions) {
each.strategy = this.getSortStrategyPerColumn(id, each.fieldName, each.strategy);
each.strategy = each.strategy ? each.strategy : this.getSortStrategyPerColumn(id, each.fieldName);
this.prepare_sorting_expression([sortingState, groupingState], each);
}

Expand Down

0 comments on commit cb6eefd

Please sign in to comment.