Skip to content

Commit aa3596a

Browse files
authored
Merge pull request #8750 from IgniteUI/fix-filtering-unboundcol-m
Always emit onFilteringDone with proper event arguments
2 parents aa42a26 + ffc9d2e commit aa3596a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

projects/igniteui-angular/src/lib/grids/filtering/grid-filtering.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ export class IgxFilteringService implements OnDestroy {
216216
this.gridAPI.filter(field, value, expressionForColumn.condition, filteringIgnoreCase);
217217
}
218218
}
219-
219+
const eventArgs = this.grid.filteringExpressionsTree.find(field) as FilteringExpressionsTree;
220220
// Wait for the change detection to update filtered data through the pipes and then emit the event.
221-
requestAnimationFrame(() => this.grid.onFilteringDone.emit(col.filteringExpressionsTree));
221+
requestAnimationFrame(() => this.grid.onFilteringDone.emit(eventArgs));
222222
}
223223

224224
/**

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,17 @@ describe('IgxGrid - Filtering actions #grid', () => {
895895
expect(grid.rowList.length).toEqual(2);
896896
}));
897897

898+
it('Should always emit onFilteringDone with proper eventArgs, even when column does not exist', fakeAsync(() => {
899+
spyOn(grid.onFilteringDone, 'emit');
900+
grid.filteringLogic = FilteringLogic.Or;
901+
grid.filter('Nonexisting', 'ignite', IgxStringFilteringOperand.instance().condition('contains'), true);
902+
tick(100);
903+
fix.detectChanges();
904+
expect(grid.rowList.length).toEqual(0);
905+
const args = grid.filteringExpressionsTree.find('Nonexisting') as FilteringExpressionsTree;
906+
expect(grid.onFilteringDone.emit).toHaveBeenCalledWith(args);
907+
}));
908+
898909
it('Should emit onFilteringDone when filtering globally', fakeAsync(() => {
899910
spyOn(grid.onFilteringDone, 'emit');
900911

0 commit comments

Comments
 (0)