Skip to content

Commit d2c27d4

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

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
@@ -615,7 +615,15 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
615615
}
616616

617617
private generateUniqueValues(columnValues: any[]) {
618-
this.uniqueValues = Array.from(new Set(columnValues));
618+
if (this.column.dataType === DataType.String && this.column.filteringIgnoreCase) {
619+
const filteredUniqueValues = columnValues.map(s => s?.toLowerCase())
620+
.reduce((map, val, i) => map.get(val) ? map : map.set(val, columnValues[i]),
621+
new Map);
622+
623+
this.uniqueValues = Array.from(filteredUniqueValues.values());
624+
} else {
625+
this.uniqueValues = Array.from(new Set(columnValues));
626+
}
619627
}
620628

621629
private generateFilterValues(isDateColumn: boolean = false) {
@@ -720,13 +728,6 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
720728

721729
this.uniqueValues.forEach(element => {
722730
if (element !== undefined && element !== null && element !== '') {
723-
if (this.column.dataType === DataType.String &&
724-
this.column.filteringIgnoreCase &&
725-
this.listData.length > 0 &&
726-
this.listData.map(el => el.label.toLowerCase()).indexOf(element.toLowerCase()) !== -1) {
727-
return;
728-
}
729-
730731
const filterListItem = new FilterListItem();
731732
if (this.column.filteringExpressionsTree) {
732733
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
@@ -4347,7 +4347,9 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
43474347

43484348
const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
43494349
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent);
4350+
43504351
expect(listItems.length).toBe(3, 'incorrect rendered list items count');
4352+
expect(listItems[1].innerText).toBe('Custom', 'incorrect list item label');
43514353
}));
43524354

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

43624364
const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
43634365
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix, searchComponent);
4366+
43644367
expect(listItems.length).toBe(5, 'incorrect rendered list items count');
4368+
expect(listItems[1].innerText).toBe('Custom', 'incorrect list item label');
4369+
expect(listItems[3].innerText).toBe('custoM', 'incorrect list item label');
4370+
expect(listItems[4].innerText).toBe('custom', 'incorrect list item label');
43654371
}));
43664372
});
43674373

0 commit comments

Comments
 (0)