Skip to content

Commit 0869982

Browse files
committed
fix(esf): improve how column values are generated
1 parent bf9b99c commit 0869982

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,15 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
494494
}
495495

496496
private generateUniqueValues(columnValues: any[]) {
497-
this.uniqueValues = Array.from(new Set(columnValues));
497+
if (this.column.dataType === DataType.String && this.column.filteringIgnoreCase) {
498+
const filteredUniqueValues = columnValues.map(s => s?.toLowerCase())
499+
.reduce((map, val, i) => map.get(val) ? map : map.set(val, columnValues[i]),
500+
new Map);
501+
502+
this.uniqueValues = Array.from(filteredUniqueValues.values());
503+
} else {
504+
this.uniqueValues = Array.from(new Set(columnValues));
505+
}
498506
}
499507

500508
private generateFilterValues(isDateColumn: boolean = false) {
@@ -599,13 +607,6 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
599607

600608
this.uniqueValues.forEach(element => {
601609
if (element !== undefined && element !== null && element !== '') {
602-
if (this.column.dataType === DataType.String &&
603-
this.column.filteringIgnoreCase &&
604-
this.listData.length > 0 &&
605-
this.listData.map(el => el.label.toLowerCase()).indexOf(element.toLowerCase()) !== -1) {
606-
return;
607-
}
608-
609610
const filterListItem = new FilterListItem();
610611
if (this.column.filteringExpressionsTree) {
611612
if (shouldUpdateSelection) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4355,7 +4355,9 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
43554355

43564356
const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
43574357
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent);
4358+
43584359
expect(listItems.length).toBe(3, 'incorrect rendered list items count');
4360+
expect(listItems[1].innerText).toBe('Custom', 'incorrect list item label');
43594361
}));
43604362

43614363
it('Should not ignore duplicate records when column\'\s filteringIgnoreCase is false', fakeAsync(() => {
@@ -4369,7 +4371,11 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
43694371

43704372
const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
43714373
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent);
4374+
43724375
expect(listItems.length).toBe(5, 'incorrect rendered list items count');
4376+
expect(listItems[1].innerText).toBe('Custom', 'incorrect list item label');
4377+
expect(listItems[3].innerText).toBe('custoM', 'incorrect list item label');
4378+
expect(listItems[4].innerText).toBe('custom', 'incorrect list item label');
43734379
}));
43744380
});
43754381

0 commit comments

Comments
 (0)