Skip to content

Commit f482baf

Browse files
authored
Merge pull request #12455 from IgniteUI/mdragnev/fix-12447
fix(grid): Emit groupingExpressionChange when sorting through the gro…
2 parents e5802ad + dd318a9 commit f482baf

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
@@ -639,6 +639,25 @@ describe('IgxGrid - GroupBy #grid', () => {
639639
expect(grid.groupingExpressionsChange.emit).toHaveBeenCalledTimes(0);
640640
}));
641641

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