Skip to content

Commit 3f55ba0

Browse files
authored
Merge branch '21.2.x' into bpachilova/combo-focusedItem-type-fix
2 parents ca6bd70 + c470743 commit 3f55ba0

3 files changed

Lines changed: 75 additions & 4 deletions

File tree

projects/igniteui-angular/grids/core/src/filtering/excel-style/excel-style-search.component.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { IgxTreeComponent, IgxTreeNodeComponent, ITreeNodeSelectionEvent } from
1414
import { IgxCircularProgressBarComponent } from 'igniteui-angular/progressbar';
1515
import { cloneHierarchicalArray, columnFieldPath, FilteringExpressionsTree, FilteringLogic, GridColumnDataType, IgxBooleanFilteringOperand, IgxDateFilteringOperand, IgxDateTimeFilteringOperand, IgxNumberFilteringOperand, IgxStringFilteringOperand, IgxTimeFilteringOperand, PlatformUtil, resolveNestedPath, ɵSize } from 'igniteui-angular/core';
1616
import { Navigate } from 'igniteui-angular/drop-down';
17+
import { GridPagingMode } from '../../common/enums';
1718

1819
@Directive({
1920
selector: '[igxExcelStyleLoading]',
@@ -501,7 +502,7 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
501502
(it.label !== null && it.label !== undefined) &&
502503
!it.isBlanks &&
503504
(it.label.toString().toLowerCase().indexOf(searchVal) > -1 ||
504-
this.matchesNumericValue(it, searchVal)));
505+
this.matchesNumericValue(it, searchVal)));
505506

506507
this.esf.listData.forEach(i => i.isSelected = false);
507508
this.displayedListData.forEach(i => i.isSelected = true);
@@ -610,7 +611,7 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
610611
searchVal = new Set(selectedItems.map(e => e.value.toLocaleTimeString()));
611612
break;
612613
case GridColumnDataType.String:
613-
if (this.esf.column.filteringIgnoreCase && !this.isHierarchical()) {
614+
if (this.esf.column.filteringIgnoreCase && !this.isHierarchical() && !this.isRemote()) {
614615
const selectedValues = new Set(selectedItems.map(item => item.value.toLowerCase()));
615616
searchVal = new Set();
616617

@@ -816,8 +817,8 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
816817
const columnDataType = this.esf.column?.dataType;
817818
if (typeof item.value !== 'number' ||
818819
(columnDataType !== GridColumnDataType.Number &&
819-
columnDataType !== GridColumnDataType.Currency &&
820-
columnDataType !== GridColumnDataType.Percent)) {
820+
columnDataType !== GridColumnDataType.Currency &&
821+
columnDataType !== GridColumnDataType.Percent)) {
821822
return false;
822823
}
823824

@@ -896,4 +897,8 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
896897
const subRequired = indexOutOfChunk || scrollNeeded;
897898
return subRequired;
898899
}
900+
901+
private isRemote(): boolean {
902+
return this.esf.grid.verticalScrollContainer.isRemote || this.esf.grid.pagingMode === GridPagingMode.Remote;
903+
}
899904
}

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
IgxGridFilteringESFEmptyTemplatesComponent,
2525
IgxGridFilteringESFTemplatesComponent,
2626
IgxGridFilteringESFLoadOnDemandComponent,
27+
IgxGridFilteringESFRemoteChunkComponent,
2728
CustomFilteringStrategyComponent,
2829
IgxGridExternalESFComponent,
2930
IgxGridExternalESFTemplateComponent,
@@ -3223,6 +3224,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
32233224
IgxGridFilteringESFEmptyTemplatesComponent,
32243225
IgxGridFilteringESFTemplatesComponent,
32253226
IgxGridFilteringESFLoadOnDemandComponent,
3227+
IgxGridFilteringESFRemoteChunkComponent,
32263228
IgxGridFilteringMCHComponent,
32273229
IgxGridExternalESFComponent,
32283230
IgxGridExternalESFTemplateComponent
@@ -7068,6 +7070,40 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
70687070
tick(2000);
70697071
}).not.toThrowError(/'dataType' of null/);
70707072
}));
7073+
7074+
it('Should preserve selected string values from full remote set when grid data is chunked', fakeAsync(() => {
7075+
const remoteFix = TestBed.createComponent(IgxGridFilteringESFRemoteChunkComponent);
7076+
const remoteGrid = remoteFix.componentInstance.grid;
7077+
remoteFix.detectChanges();
7078+
7079+
// Mark the grid as remote so ESF does not derive selected values from the current data chunk.
7080+
remoteGrid.totalItemCount = remoteFix.componentInstance.fullData.length;
7081+
7082+
GridFunctions.clickExcelFilterIcon(remoteFix, 'ProductName');
7083+
tick(100);
7084+
remoteFix.detectChanges();
7085+
7086+
const excelMenu = GridFunctions.getExcelStyleFilteringComponent(remoteFix);
7087+
const labelElements: any[] = Array.from(GridFunctions.getExcelStyleSearchComponentListItems(remoteFix, excelMenu));
7088+
const checkboxElements: any[] = Array.from(GridFunctions.getExcelStyleFilteringCheckboxes(remoteFix, excelMenu));
7089+
7090+
const uncheckLabel = 'Alpha';
7091+
const uncheckIndex = labelElements.findIndex(el => el.innerText === uncheckLabel);
7092+
expect(uncheckIndex).toBeGreaterThan(0);
7093+
7094+
checkboxElements[uncheckIndex].click();
7095+
remoteFix.detectChanges();
7096+
7097+
GridFunctions.clickApplyExcelStyleFiltering(remoteFix, excelMenu, 'igx-grid');
7098+
remoteFix.detectChanges();
7099+
7100+
const tree = remoteGrid.filteringExpressionsTree.filteringOperands[0] as IFilteringExpressionsTree;
7101+
const operand = tree.filteringOperands[0] as IFilteringExpression;
7102+
7103+
const selectedValues = Array.from((operand.searchVal as Set<string>).values());
7104+
expect(selectedValues).toEqual(jasmine.arrayContaining(['beta', 'Gamma', 'DELTA']));
7105+
expect(selectedValues).not.toContain('Alpha');
7106+
}));
70717107
});
70727108

70737109
describe(null, () => {

projects/igniteui-angular/test-utils/grid-samples.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,36 @@ export class IgxGridFilteringESFLoadOnDemandComponent extends BasicGridComponent
874874
};
875875
}
876876

877+
@Component({
878+
template: `<igx-grid [data]="data" height="500px" [allowFiltering]="true"
879+
[filterMode]="'excelStyleFilter'" [uniqueColumnValuesStrategy]="columnValuesStrategy">
880+
<igx-column width="100px" [field]="'ID'"></igx-column>
881+
<igx-column width="100px" [field]="'ProductName'" dataType="string"></igx-column>
882+
</igx-grid>`,
883+
imports: [IgxGridComponent, IgxColumnComponent]
884+
})
885+
export class IgxGridFilteringESFRemoteChunkComponent extends BasicGridComponent {
886+
public fullData = [
887+
{ ID: 1, ProductName: 'Alpha' },
888+
{ ID: 2, ProductName: 'beta' },
889+
{ ID: 3, ProductName: 'Gamma' },
890+
{ ID: 4, ProductName: 'DELTA' }
891+
];
892+
893+
// Simulate remote virtualization where the grid keeps only the current chunk.
894+
public override data = this.fullData.slice(0, 2);
895+
896+
private _filteringStrategy = new FilteringStrategy();
897+
898+
public columnValuesStrategy = (column: IgxColumnComponent,
899+
columnExprTree: IFilteringExpressionsTree,
900+
done: (uniqueValues: any[]) => void) => {
901+
const filteredData = this._filteringStrategy.filter(this.fullData, columnExprTree, null, null);
902+
const columnValues = filteredData.map(record => record[column.field]);
903+
done(columnValues);
904+
};
905+
}
906+
877907
@Component({
878908
template: `<igx-grid [data]="data" height="500px" [allowFiltering]="true" [filterMode]="'excelStyleFilter'" [moving]="true">
879909
<igx-column width="100px" [field]="'ID'" [header]="'ID'" [hasSummary]="true"

0 commit comments

Comments
 (0)