Skip to content

Commit f48a201

Browse files
Merge pull request #6498 from IgniteUI/dmdimitrov/issue5993-8.2.x
fix(adv-filtering): added header name property to filtering expression #5993
2 parents 67c839b + 8ace844 commit f48a201

File tree

6 files changed

+59
-9
lines changed

6 files changed

+59
-9
lines changed

projects/igniteui-angular/src/lib/grids/filtering/advanced-filtering/advanced-filtering-dialog.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ <h6 class="igx-filter-empty__title">
9696
(onRemove)="onChipRemove(expressionItem)"
9797
(onSelectionDone)="onChipSelectionEnd()"
9898
>
99-
<span igxPrefix class="igx-filter-tree__expression-column">{{ expressionItem.expression.fieldName }}</span>
99+
<span igxPrefix class="igx-filter-tree__expression-column">{{ expressionItem.columnHeader || expressionItem.expression.fieldName }}</span>
100100
<igx-icon
101101
igxPrefix
102102
fontSet="filtering-icons"

projects/igniteui-angular/src/lib/grids/filtering/advanced-filtering/advanced-filtering-dialog.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class ExpressionOperandItem extends ExpressionItem {
5656
inEditMode: boolean;
5757
inAddMode: boolean;
5858
hovered: boolean;
59+
columnHeader: string;
5960
}
6061

6162
/**
@@ -303,6 +304,7 @@ export class IgxAdvancedFilteringDialogComponent implements AfterViewInit, OnDes
303304
this.editedExpression.expression.fieldName = this.selectedColumn.field;
304305
this.editedExpression.expression.condition = this.selectedColumn.filters.condition(this.selectedCondition);
305306
this.editedExpression.expression.searchVal = DataUtil.parseValue(this.selectedColumn.dataType, this.searchValue);
307+
this.editedExpression.columnHeader = this.selectedColumn.header;
306308

307309
this.editedExpression.inEditMode = false;
308310
this.editedExpression = null;
@@ -386,6 +388,8 @@ export class IgxAdvancedFilteringDialogComponent implements AfterViewInit, OnDes
386388
ignoreCase: filteringExpr.ignoreCase
387389
};
388390
const operandItem = new ExpressionOperandItem(exprCopy, groupItem);
391+
const column = this.grid.getColumnByName(filteringExpr.fieldName);
392+
operandItem.columnHeader = column.header;
389393
groupItem.children.push(operandItem);
390394
}
391395
}

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

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,52 @@ describe('IgxGrid - Advanced Filtering', () => {
380380
.toBe(false, 'Button icon indicates there is active filtering.');
381381
}));
382382

383+
it('Should correctly display header name in select dropdown and in chip expression.', fakeAsync(() => {
384+
// Open Advanced Filtering dialog.
385+
GridFunctions.clickAdvancedFilteringButton(fix);
386+
fix.detectChanges();
387+
388+
// Click the initial 'Add And Group' button.
389+
const addAndGroupButton = GridFunctions.getAdvancedFilteringInitialAddGroupButtons(fix)[0];
390+
addAndGroupButton.click();
391+
tick(100);
392+
fix.detectChanges();
393+
394+
// Open column dropdown and verify header name is displayed for first item
395+
GridFunctions.clickAdvancedFilteringColumnSelect(fix);
396+
fix.detectChanges();
397+
const dropdownItems = GridFunctions.getAdvancedFilteringSelectDropdownItems(fix);
398+
expect(dropdownItems[0].innerText).toBe('HeaderID');
399+
400+
selectColumnInEditModeExpression(fix, 0); // Select 'HeaderID' column
401+
selectOperatorInEditModeExpression(fix, 0); // Select 'Contains' operator.
402+
const input = GridFunctions.getAdvancedFilteringValueInput(fix).querySelector('input');
403+
sendInputNativeElement(fix, input, 'a'); // Type filter value.
404+
405+
// Commit the populated expression.
406+
GridFunctions.clickAdvancedFilteringExpressionCommitButton(fix);
407+
fix.detectChanges();
408+
409+
// Verify header name in chip text
410+
verifyExpressionChipContent(fix, [0], 'HeaderID', 'Contains', 'a');
411+
412+
// Apply the filters.
413+
GridFunctions.clickAdvancedFilteringApplyButton(fix);
414+
fix.detectChanges();
415+
416+
// Close Advanced Filtering dialog.
417+
GridFunctions.clickAdvancedFilteringCancelButton(fix);
418+
tick(100);
419+
fix.detectChanges();
420+
421+
// Open Advanced Filtering dialog again.
422+
GridFunctions.clickAdvancedFilteringButton(fix);
423+
fix.detectChanges();
424+
425+
// Verify header name in chip text
426+
verifyExpressionChipContent(fix, [0], 'HeaderID', 'Contains', 'a');
427+
}));
428+
383429
it('Should correctly filter by a \'string\' column through UI.', fakeAsync(() => {
384430
// Test prerequisites
385431
grid.height = '800px';
@@ -894,7 +940,7 @@ describe('IgxGrid - Advanced Filtering', () => {
894940
fix.detectChanges();
895941
const dropdownItems = GridFunctions.getAdvancedFilteringSelectDropdownItems(fix);
896942
expect(dropdownItems.length).toBe(3);
897-
expect(dropdownItems[0].innerText).toBe('ID');
943+
expect(dropdownItems[0].innerText).toBe('HeaderID');
898944
expect(dropdownItems[1].innerText).toBe('ProductName');
899945
expect(dropdownItems[2].innerText).toBe('Another Field');
900946
}));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ export class IgxTestExcelFilteringDatePickerComponent extends IgxGridFilteringCo
11781178

11791179
@Component({
11801180
template: `<igx-grid [data]="data" height="500px" [allowAdvancedFiltering]="true" [showToolbar]="true">
1181-
<igx-column width="100px" [field]="'ID'" [header]="'ID'" [hasSummary]="true"></igx-column>
1181+
<igx-column width="100px" [field]="'ID'" [header]="'HeaderID'" [hasSummary]="true"></igx-column>
11821182
<igx-column width="100px" [field]="'ProductName'" dataType="string"></igx-column>
11831183
<igx-column width="100px" [field]="'Downloads'" dataType="number" [hasSummary]="true"></igx-column>
11841184
<igx-column width="100px" [field]="'Released'" dataType="boolean"></igx-column>

src/app/grid-filtering/grid-filtering.sample.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
exportExcelText="Export to Excel"
3131
exportCsvText="Export to CSV">
3232
<igx-column *ngFor="let c of columns" [field]="c.field"
33-
[header]="c.field"
33+
[header]="c.header"
3434
[movable]="c.movable"
3535
[groupable]="true"
3636
[resizable]="c.resizable"

src/app/grid-filtering/grid-filtering.sample.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ export class GridFilteringComponent implements OnInit, AfterViewInit {
7878

7979
this.columns = [
8080
{ field: 'ID', width: 80, resizable: true, movable: true, type: 'string' },
81-
{ field: 'CompanyName', width: 150, resizable: true, movable: true, type: 'string'},
82-
{ field: 'ContactName', width: 150, resizable: true, movable: true, type: 'string' },
81+
{ field: 'CompanyName', header: 'Company Name', width: 175, resizable: true, movable: true, type: 'string'},
82+
{ field: 'ContactName', header: 'Contact Name', width: 175, resizable: true, movable: true, type: 'string' },
8383
{ field: 'Employees', width: 150, resizable: true, movable: true, type: 'number' },
84-
{ field: 'ContactTitle', width: 150, resizable: true, movable: true, type: 'string' },
85-
{ field: 'DateCreated', width: 150, resizable: true, movable: true, type: 'date' },
84+
{ field: 'ContactTitle', header: 'Contact Title', width: 150, resizable: true, movable: true, type: 'string' },
85+
{ field: 'DateCreated', header: 'Date Created', width: 150, resizable: true, movable: true, type: 'date' },
8686
{ field: 'Address', width: 150, resizable: true, movable: true, type: 'string' },
8787
{ field: 'City', width: 150, resizable: true, movable: true, type: 'string' },
8888
{ field: 'Region', width: 150, resizable: true, movable: true, type: 'string' },
89-
{ field: 'PostalCode', width: 150, resizable: true, movable: true, type: 'string' },
89+
{ field: 'PostalCode', header: 'Postal Code', width: 150, resizable: true, movable: true, type: 'string' },
9090
{ field: 'Phone', width: 150, resizable: true, movable: true, type: 'string' },
9191
{ field: 'Fax', width: 150, resizable: true, movable: true, type: 'string' },
9292
{ field: 'Contract', width: 150, resizable: true, movable: true, type: 'boolean' }

0 commit comments

Comments
 (0)