Skip to content

Commit 87d2954

Browse files
committed
fix(grid): Emit groupingExpressionChange when sorting through the group by chips
1 parent 9861f2c commit 87d2954

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid.groupby.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,25 @@ describe('IgxGrid - GroupBy #grid', () => {
640640
expect(grid.groupingExpressionsChange.emit).toHaveBeenCalledTimes(0);
641641
}));
642642

643+
it('should emit groupingExpressionsChange when a group is sorted through the chip', fakeAsync(() => {
644+
const fix = TestBed.createComponent(DefaultGridComponent);
645+
fix.detectChanges();
646+
647+
// group by string column
648+
const grid = fix.componentInstance.instance;
649+
fix.detectChanges();
650+
grid.groupBy({
651+
fieldName: 'ReleaseDate', dir: SortingDirection.Asc, ignoreCase: false
652+
});
653+
fix.detectChanges();
654+
spyOn(grid.groupingExpressionsChange, 'emit');
655+
fix.detectChanges();
656+
const chips = grid.groupArea.chips;
657+
grid.groupArea.handleClick(chips.first.id);
658+
fix.detectChanges();
659+
expect(grid.groupingExpressionsChange.emit).toHaveBeenCalledTimes(1);
660+
}));
661+
643662
it('should group unbound column with custom grouping strategy', fakeAsync(() => {
644663
const fix = TestBed.createComponent(GroupableGridComponent);
645664
fix.componentInstance.data.forEach((r, i) => {

projects/igniteui-angular/src/lib/grids/grouping/group-by-area.directive.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { IgxColumnMovingDragDirective } from '../moving/moving.drag.directive';
2424
*
2525
* @hidden @internal
2626
*/
27-
@Directive()
27+
@Directive()
2828
export abstract class IgxGroupByAreaDirective {
2929
/**
3030
* The drop area template if provided by the parent grid.
@@ -37,7 +37,7 @@ export abstract class IgxGroupByAreaDirective {
3737
public density: DisplayDensity = DisplayDensity.comfortable;
3838

3939
@HostBinding('class.igx-grid-grouparea')
40-
public defaultClass = true;
40+
public defaultClass = true;
4141

4242
@HostBinding('class.igx-grid-grouparea--cosy')
4343
public get cosyStyle() {
@@ -118,7 +118,7 @@ export abstract class IgxGroupByAreaDirective {
118118
this.updateGroupSorting(id);
119119
}
120120

121-
public onDragDrop(event) {
121+
public onDragDrop(event) {
122122
const drag: IgxColumnMovingDragDirective = event.detail.owner;
123123
if (drag instanceof IgxColumnMovingDragDirective) {
124124
const column = drag.column;
@@ -161,6 +161,8 @@ export abstract class IgxGroupByAreaDirective {
161161
protected updateGroupSorting(id: string) {
162162
const expr = this.expressions.find(e => e.fieldName === id);
163163
expr.dir = 3 - expr.dir;
164+
const expressionsChangeEvent = this.grid.groupingExpressionsChange || this.expressionsChange;
165+
expressionsChangeEvent.emit(this.expressions);
164166
this.grid.pipeTrigger++;
165167
this.grid.notifyChanges();
166168
}

0 commit comments

Comments
 (0)