Skip to content

Commit 399c438

Browse files
Merge pull request #6530 from IgniteUI/dmdimitrov/issue5993-master
fix(adv-filtering): added header name property to filtering expression #5993
2 parents ac576f9 + 1972aed commit 399c438

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
@@ -99,7 +99,7 @@ <h6 class="igx-filter-empty__title">
9999
(onRemove)="onChipRemove(expressionItem)"
100100
(onSelectionDone)="onChipSelectionEnd()"
101101
>
102-
<span igxPrefix class="igx-filter-tree__expression-column">{{ expressionItem.expression.fieldName }}</span>
102+
<span igxPrefix class="igx-filter-tree__expression-column">{{ expressionItem.columnHeader || expressionItem.expression.fieldName }}</span>
103103
<igx-icon
104104
igxPrefix
105105
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
/**
@@ -470,6 +471,7 @@ export class IgxAdvancedFilteringDialogComponent implements AfterViewInit, OnDes
470471
this.editedExpression.expression.fieldName = this.selectedColumn.field;
471472
this.editedExpression.expression.condition = this.selectedColumn.filters.condition(this.selectedCondition);
472473
this.editedExpression.expression.searchVal = DataUtil.parseValue(this.selectedColumn.dataType, this.searchValue);
474+
this.editedExpression.columnHeader = this.selectedColumn.header;
473475

474476
this.editedExpression.inEditMode = false;
475477
this.editedExpression = null;
@@ -568,6 +570,8 @@ export class IgxAdvancedFilteringDialogComponent implements AfterViewInit, OnDes
568570
ignoreCase: filteringExpr.ignoreCase
569571
};
570572
const operandItem = new ExpressionOperandItem(exprCopy, groupItem);
573+
const column = this.grid.getColumnByName(filteringExpr.fieldName);
574+
operandItem.columnHeader = column.header;
571575
groupItem.children.push(operandItem);
572576
}
573577
}

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
@@ -382,6 +382,52 @@ describe('IgxGrid - Advanced Filtering #grid', () => {
382382
.toBe(false, 'Button indicates there is active filtering.');
383383
}));
384384

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

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
@@ -1218,7 +1218,7 @@ export class IgxTestExcelFilteringDatePickerComponent extends IgxGridFilteringCo
12181218

12191219
@Component({
12201220
template: `<igx-grid [data]="data" height="500px" [allowAdvancedFiltering]="true" [showToolbar]="true">
1221-
<igx-column width="100px" [field]="'ID'" [header]="'ID'" [hasSummary]="true"></igx-column>
1221+
<igx-column width="100px" [field]="'ID'" [header]="'HeaderID'" [hasSummary]="true"></igx-column>
12221222
<igx-column width="100px" [field]="'ProductName'" dataType="string"></igx-column>
12231223
<igx-column width="100px" [field]="'Downloads'" dataType="number" [hasSummary]="true"></igx-column>
12241224
<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
@@ -31,7 +31,7 @@
3131
exportExcelText="Export to Excel"
3232
exportCsvText="Export to CSV">
3333
<igx-column *ngFor="let c of columns" [field]="c.field"
34-
[header]="c.field"
34+
[header]="c.header"
3535
[movable]="c.movable"
3636
[groupable]="true"
3737
[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
@@ -77,15 +77,15 @@ export class GridFilteringComponent implements OnInit, AfterViewInit {
7777

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

0 commit comments

Comments
 (0)