Skip to content

Commit 966abea

Browse files
authored
Merge pull request #8511 from IgniteUI/ibarakov/fix-7878-master
Add Excel style filtering header icon template
2 parents 31993da + efba47a commit 966abea

File tree

12 files changed

+86
-8
lines changed

12 files changed

+86
-8
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Ignite UI for Angular Change Log
22

33
All notable changes for each version of this project will be documented in this file.
4+
## 11.0.0
5+
6+
### General
7+
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
8+
- Added a new directive for re-templating the Excel style filtering header icon - `IgxExcelStyleHeaderIconDirective`.
9+
410
## 10.2.0
511

612
### General

projects/igniteui-angular/src/lib/core/styles/components/grid/_excel-filtering-theme.scss

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@
3737
}
3838

3939
%grid-excel-icon {
40+
display: flex;
4041
cursor: pointer;
4142

42-
&.igx-icon {
43+
igx-icon {
4344
width: rem(15px);
4445
height: rem(15px);
4546
font-size: rem(15px);
4647
}
4748
}
4849

4950
%grid-excel-icon--filtered {
50-
&.igx-icon {
51+
igx-icon {
5152
color: if(
5253
$variant == 'indigo-design',
5354
igx-color($palette, 'warn', 500),

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ import { IgxColumnResizingService } from './resizing/resizing.service';
101101
import { IFilteringStrategy } from '../data-operations/filtering-strategy';
102102
import {
103103
IgxRowExpandedIndicatorDirective, IgxRowCollapsedIndicatorDirective,
104-
IgxHeaderExpandIndicatorDirective, IgxHeaderCollapseIndicatorDirective
104+
IgxHeaderExpandIndicatorDirective, IgxHeaderCollapseIndicatorDirective, IgxExcelStyleHeaderIconDirective
105105
} from './grid/grid.directives';
106106
import {
107107
GridKeydownTargetType,
@@ -229,6 +229,12 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
229229
@ViewChild('defaultCollapsedTemplate', { read: TemplateRef, static: true })
230230
protected defaultCollapsedTemplate: TemplateRef<any>;
231231

232+
/**
233+
* @hidden @internal
234+
*/
235+
@ViewChild('defaultESFHeaderIcon', { read: TemplateRef, static: true })
236+
protected defaultESFHeaderIconTemplate: TemplateRef<any>;
237+
232238
/**
233239
* Gets/Sets the resource strings.
234240
* @remarks
@@ -1994,6 +2000,12 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
19942000
@ContentChild(IgxHeaderCollapseIndicatorDirective, { read: TemplateRef })
19952001
public headerCollapseIndicatorTemplate: TemplateRef<any> = null;
19962002

2003+
/**
2004+
* The custom template, if any, that should be used when rendering a row expand indicator.
2005+
*/
2006+
@ContentChild(IgxExcelStyleHeaderIconDirective, { read: TemplateRef })
2007+
public excelStyleHeaderIconTemplate: TemplateRef<any> = null;
2008+
19972009
/**
19982010
* @hidden
19992011
* @internal

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

+9
Original file line numberDiff line numberDiff line change
@@ -5112,6 +5112,15 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
51125112
listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix);
51135113
expect(listItems[1].innerText).not.toBe('(Blanks)');
51145114
}));
5115+
5116+
it('Should use custom excel style filter icon instead of default one.', fakeAsync(() => {
5117+
const header = GridFunctions.getColumnHeader('AnotherField', fix);
5118+
fix.detectChanges();
5119+
const icon = GridFunctions.getHeaderFilterIcon(header);
5120+
fix.detectChanges();
5121+
expect(icon).not.toBeNull();
5122+
expect(icon.nativeElement.textContent.toLowerCase().trim()).toBe('filter_alt');
5123+
}));
51155124
});
51165125

51175126
describe('Load values on demand', () => {

projects/igniteui-angular/src/lib/grids/grid/grid.directives.ts

+9
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ export class IgxHeaderExpandIndicatorDirective {
6363
export class IgxHeaderCollapseIndicatorDirective {
6464
}
6565

66+
/**
67+
* @hidden
68+
*/
69+
@Directive({
70+
selector: '[igxExcelStyleHeaderIcon]'
71+
})
72+
export class IgxExcelStyleHeaderIconDirective {
73+
}
74+
6675
/**
6776
* @hidden
6877
*/

projects/igniteui-angular/src/lib/grids/grid/grid.module.ts

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
IgxGroupAreaDropDirective,
44
IgxGroupByRowTemplateDirective,
55
IgxRowExpandedIndicatorDirective,
6+
IgxExcelStyleHeaderIconDirective,
67
IgxRowCollapsedIndicatorDirective,
78
IgxHeaderExpandIndicatorDirective,
89
IgxHeaderCollapseIndicatorDirective,
@@ -32,6 +33,7 @@ import { IgxGridExpandableCellComponent } from './expandable-cell.component';
3233
IgxGroupByRowTemplateDirective,
3334
IgxGridDetailTemplateDirective,
3435
IgxRowExpandedIndicatorDirective,
36+
IgxExcelStyleHeaderIconDirective,
3537
IgxRowCollapsedIndicatorDirective,
3638
IgxHeaderExpandIndicatorDirective,
3739
IgxHeaderCollapseIndicatorDirective,
@@ -52,6 +54,7 @@ import { IgxGridExpandableCellComponent } from './expandable-cell.component';
5254
IgxGroupByRowTemplateDirective,
5355
IgxGridDetailTemplateDirective,
5456
IgxRowExpandedIndicatorDirective,
57+
IgxExcelStyleHeaderIconDirective,
5558
IgxRowCollapsedIndicatorDirective,
5659
IgxHeaderExpandIndicatorDirective,
5760
IgxHeaderCollapseIndicatorDirective,

projects/igniteui-angular/src/lib/grids/headers/grid-header.component.html

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<span [title]="columnTitle">{{ column.header || column.field }}</span>
33
</ng-template>
44

5+
<ng-template #defaultESFHeaderIconTemplate>
6+
<igx-icon>more_vert</igx-icon>
7+
</ng-template>
8+
59
<span class="igx-grid__th-title">
610
<ng-container *ngTemplateOutlet="column.headerTemplate ? column.headerTemplate : defaultColumn; context: { $implicit: column, column: column}">
711
</ng-container>
@@ -16,8 +20,13 @@
1620
{{sortingIcon}}
1721
</igx-icon>
1822

19-
<igx-icon [ngClass]="filterIconClassName" [attr.draggable]="false" (click)="onFilteringIconClick($event)"
20-
*ngIf="grid.allowFiltering == true && column.filterable && grid.filterMode == 'excelStyleFilter'">
21-
more_vert
22-
</igx-icon>
23+
<div *ngIf="grid.allowFiltering == true && column.filterable && grid.filterMode == 'excelStyleFilter'"
24+
(click)="onFilteringIconClick($event)"
25+
(pointerdown)="$event.stopPropagation()"
26+
[ngClass]="filterIconClassName">
27+
28+
<ng-container *ngTemplateOutlet="esfIconTemplate; context: { $implicit: this }">
29+
</ng-container>
30+
</div>
31+
2332
</div>

projects/igniteui-angular/src/lib/grids/headers/grid-header.component.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import {
88
HostListener,
99
Input,
1010
NgZone,
11-
OnDestroy
11+
OnDestroy,
12+
TemplateRef,
13+
ViewChild
1214
} from '@angular/core';
1315
import { DataType } from '../../data-operations/data-util';
1416
import { SortingDirection } from '../../data-operations/sorting-expression.interface';
@@ -34,6 +36,12 @@ export class IgxGridHeaderComponent implements DoCheck, OnDestroy {
3436

3537
private _destroy$ = new Subject<boolean>();
3638

39+
/**
40+
* @hidden
41+
*/
42+
@ViewChild('defaultESFHeaderIconTemplate', { read: TemplateRef, static: true })
43+
protected defaultESFHeaderIconTemplate: TemplateRef<any>;
44+
3745
@Input()
3846
public column: IgxColumnComponent;
3947

@@ -83,6 +91,13 @@ export class IgxGridHeaderComponent implements DoCheck, OnDestroy {
8391
return null;
8492
}
8593

94+
/**
95+
* @hidden
96+
*/
97+
public get esfIconTemplate() {
98+
return this.grid.excelStyleHeaderIconTemplate || this.defaultESFHeaderIconTemplate;
99+
}
100+
86101
get ascending() {
87102
return this.sortDirection === SortingDirection.Asc;
88103
}

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
350350
this.rowCollapsedIndicatorTemplate = this.rootGrid.rowCollapsedIndicatorTemplate;
351351
this.headerCollapseIndicatorTemplate = this.rootGrid.headerCollapseIndicatorTemplate;
352352
this.headerExpandIndicatorTemplate = this.rootGrid.headerExpandIndicatorTemplate;
353+
this.excelStyleHeaderIconTemplate = this.rootGrid.excelStyleHeaderIconTemplate;
353354
this.hasChildrenKey = this.parentIsland ?
354355
this.parentIsland.hasChildrenKey || this.rootGrid.hasChildrenKey :
355356
this.rootGrid.hasChildrenKey;

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

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const GRID_FOOTER_CLASS = '.igx-grid__tfoot';
6767
const GRID_CONTENT_CLASS = '.igx-grid__tbody-content';
6868
const DISPLAY_CONTAINER = 'igx-display-container';
6969
const SORT_ICON_CLASS = '.sort-icon';
70+
const FILTER_ICON_CLASS = '.igx-excel-filter__icon';
7071
const SELECTED_COLUMN_CLASS = 'igx-grid__th--selected';
7172
const HOVERED_COLUMN_CLASS = 'igx-grid__th--selectable';
7273
const SELECTED_COLUMN_CELL_CLASS = 'igx-grid__td--column-selected';
@@ -1871,6 +1872,10 @@ export class GridFunctions {
18711872
return header.query(By.css(SORT_ICON_CLASS));
18721873
}
18731874

1875+
public static getHeaderFilterIcon(header: DebugElement): DebugElement {
1876+
return header.query(By.css(FILTER_ICON_CLASS));
1877+
}
1878+
18741879
public static clickHeaderSortIcon(header: DebugElement) {
18751880
const sortIcon = header.query(By.css(SORT_ICON_CLASS));
18761881
sortIcon.triggerEventHandler('click', new Event('click'));

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

+4
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,10 @@ export class IgxGridFilteringESFEmptyTemplatesComponent extends BasicGridCompone
12321232
dataType="string" [filters]="customFilter" [sortable]="'true'" [movable]="'true'">
12331233
</igx-column>
12341234
1235+
<ng-template igxExcelStyleHeaderIcon>
1236+
<igx-icon>filter_alt</igx-icon>
1237+
</ng-template>
1238+
12351239
<igx-grid-excel-style-filtering [minHeight]="'0px'" [maxHeight]="'500px'">
12361240
<igx-excel-style-column-operations>
12371241
<igx-excel-style-moving></igx-excel-style-moving>

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

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ <h3>ESF Templates</h3>
8989
[dataType]="c.type">
9090
</igx-column>
9191

92+
<ng-template igxExcelStyleHeaderIcon>
93+
<igx-icon>filter_alt</igx-icon>
94+
</ng-template>
95+
9296
<igx-grid-excel-style-filtering [minHeight]="'700px'" [maxHeight]="'none'">
9397
<div igxExcelStyleColumnOperations>COLUMN OPERATIONS
9498
<igx-excel-style-header></igx-excel-style-header>

0 commit comments

Comments
 (0)