Skip to content

Commit df7b778

Browse files
committed
Merge branch 'pivot-grid-master' of https://github.com/IgniteUI/igniteui-angular into mdragnev/fix-10412
2 parents 6a35b66 + 1c9e3e3 commit df7b778

16 files changed

+448
-47
lines changed

projects/igniteui-angular/src/lib/data-operations/pivot-strategy.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

2+
import { GridType } from '../grids/common/grid.interface';
3+
import { IgxPivotGridComponent } from '../grids/pivot-grid/pivot-grid.component';
24
import { IPivotDimension, IPivotKeys, IPivotValue, PivotDimensionType } from '../grids/pivot-grid/pivot-grid.interface';
35
import { PivotUtil } from '../grids/pivot-grid/pivot-util';
6+
import { FilteringStrategy } from './filtering-strategy';
47

58
export interface IPivotDimensionStrategy {
69
process(collection: any,
@@ -149,3 +152,24 @@ export class PivotColumnDimensionsStrategy implements IPivotDimensionStrategy {
149152
return !(record[pivotKeys.records] && record[pivotKeys.records].some(r => r[pivotKeys.records]));
150153
}
151154
}
155+
156+
export class DimensionValuesFilteringStrategy extends FilteringStrategy {
157+
/**
158+
* Creates a new instance of FormattedValuesFilteringStrategy.
159+
*
160+
* @param fields An array of column field names that should be formatted.
161+
* If omitted the values of all columns which has formatter will be formatted.
162+
*/
163+
constructor(private fields?: string[]) {
164+
super();
165+
}
166+
167+
protected getFieldValue(rec: any, fieldName: string, isDate: boolean = false, isTime: boolean = false,
168+
grid?: IgxPivotGridComponent): any {
169+
const config = grid.pivotConfiguration;
170+
const allDimensions = config.rows.concat(config.columns).concat(config.filters).filter(x => x !== null);
171+
const enabledDimensions = allDimensions.filter(x => x && x.enabled);
172+
const dim = PivotUtil.flatten(enabledDimensions).find(x => x.memberName === fieldName);
173+
return PivotUtil.extractValueFromDimension(dim, rec);
174+
}
175+
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,12 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
397397
});
398398
}
399399
}
400-
401-
this.esf.grid.filteringService.filterInternal(this.esf.column.field, filterTree);
400+
const grid = this.esf.grid;
401+
const col = this.esf.column;
402+
grid.filteringService.filterInternal(col.field, filterTree);
402403
this.esf.expressionsList = new Array<ExpressionUI>();
403-
this.esf.grid.filteringService.generateExpressionsList(this.esf.column.filteringExpressionsTree,
404-
this.esf.grid.filteringLogic, this.esf.expressionsList);
404+
grid.filteringService.generateExpressionsList(col.filteringExpressionsTree,
405+
grid.filteringLogic, this.esf.expressionsList);
405406
} else {
406407
this.esf.grid.filteringService.clearFilter(this.esf.column.field);
407408
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class IgxFilteringService implements OnDestroy {
8181
this.initFilteringSettings();
8282
this.column = column;
8383
const filterIcon = this.column.filteringExpressionsTree ? 'igx-excel-filter__icon--filtered' : 'igx-excel-filter__icon';
84-
const filterIconTarget = element.querySelector(`.${filterIcon}`) as HTMLElement;
84+
const filterIconTarget = element.querySelector(`.${filterIcon}`) as HTMLElement || element;
8585

8686
this._filterMenuOverlaySettings.target = filterIconTarget;
8787
this._filterMenuOverlaySettings.outlet = (this.grid as any).outlet;
@@ -555,7 +555,7 @@ export class IgxFilteringService implements OnDestroy {
555555
return true;
556556
}
557557

558-
private filter_internal(fieldName: string, term, conditionOrExpressionsTree: IFilteringOperation | IFilteringExpressionsTree,
558+
protected filter_internal(fieldName: string, term, conditionOrExpressionsTree: IFilteringOperation | IFilteringExpressionsTree,
559559
ignoreCase: boolean) {
560560
const grid = this.grid;
561561
const filteringTree = grid.filteringExpressionsTree;
@@ -578,7 +578,7 @@ export class IgxFilteringService implements OnDestroy {
578578
* If createNewTree is true, filteringState will not be modified (because it directly affects the grid.filteringExpressionsTree),
579579
* but a new object is created and returned.
580580
*/
581-
private prepare_filtering_expression(
581+
protected prepare_filtering_expression(
582582
filteringState: IFilteringExpressionsTree,
583583
fieldName: string,
584584
searchVal,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Injectable } from '@angular/core';
2+
import { IFilteringOperation } from '../../data-operations/filtering-condition';
3+
import { FilteringLogic } from '../../data-operations/filtering-expression.interface';
4+
import { FilteringExpressionsTree, IFilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree';
5+
import { IgxFilteringService } from '../filtering/grid-filtering.service';
6+
import { IgxPivotGridComponent } from './pivot-grid.component';
7+
import { PivotUtil } from './pivot-util';
8+
9+
@Injectable()
10+
export class IgxPivotFilteringService extends IgxFilteringService {
11+
public clearFilter(field: string): void {
12+
this.clear_filter(field);
13+
}
14+
15+
public clear_filter(fieldName: string) {
16+
super.clear_filter(fieldName);
17+
const grid = this.grid;
18+
const config = (grid as IgxPivotGridComponent).pivotConfiguration;
19+
const allDimensions = PivotUtil.flatten(config.rows.concat(config.columns).concat(config.filters).filter(x => x !== null));
20+
const enabledDimensions = allDimensions.filter(x => x && x.enabled);
21+
const dim = enabledDimensions.find(x => x.memberName === fieldName || x.member === fieldName);
22+
dim.filters = undefined;
23+
grid.filteringPipeTrigger++;
24+
if (PivotUtil.flatten(config.columns).indexOf(dim) !== -1) {
25+
// update columns
26+
(grid as any).setupColumns();
27+
}
28+
}
29+
protected filter_internal(fieldName: string, term, conditionOrExpressionsTree: IFilteringOperation | IFilteringExpressionsTree,
30+
ignoreCase: boolean) {
31+
super.filter_internal(fieldName, term, conditionOrExpressionsTree, ignoreCase);
32+
const grid = this.grid;
33+
const config = (grid as IgxPivotGridComponent).pivotConfiguration;
34+
const allDimensions = PivotUtil.flatten(config.rows.concat(config.columns).concat(config.filters).filter(x => x !== null));
35+
const enabledDimensions = allDimensions.filter(x => x && x.enabled);
36+
const dim = enabledDimensions.find(x => x.memberName === fieldName || x.member === fieldName);
37+
const filteringTree = dim.filters || new FilteringExpressionsTree(FilteringLogic.And);
38+
const fieldFilterIndex = filteringTree.findIndex(fieldName);
39+
if (fieldFilterIndex > -1) {
40+
filteringTree.filteringOperands.splice(fieldFilterIndex, 1);
41+
}
42+
43+
this.prepare_filtering_expression(filteringTree, fieldName, term, conditionOrExpressionsTree, ignoreCase, fieldFilterIndex);
44+
dim.filters = filteringTree;
45+
grid.filteringPipeTrigger++;
46+
if (PivotUtil.flatten(config.columns).indexOf(dim) !== -1) {
47+
// update columns
48+
(grid as any).setupColumns();
49+
}
50+
}
51+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { IgxGridNavigationService } from '../grid-navigation.service';
2+
import { Injectable } from '@angular/core';
3+
import { IgxPivotGridComponent } from './pivot-grid.component';
4+
5+
@Injectable()
6+
export class IgxPivotGridNavigationService extends IgxGridNavigationService {
7+
public grid: IgxPivotGridComponent;
8+
9+
public dispatchEvent(event: KeyboardEvent) {
10+
// TODO
11+
}
12+
}

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
(copy)="copyHandler($event)"
1616
(keydown)="navigation.headerNavigation($event)"
1717
(scroll)="preventHeaderScroll($event)"
18-
(focus)="navigation.focusFirstCell()"
1918
>
2019
</igx-pivot-header-row>
2120

2221
<div igxGridBody (keydown.control.c)="copyHandler($event)" (copy)="copyHandler($event)" class="igx-grid__tbody" role="rowgroup">
23-
<div class="igx-grid__tbody-content" tabindex="0" [attr.role]="dataView.length ? null : 'row'" (keydown)="navigation.handleNavigation($event)" (focus)="navigation.focusTbody($event)"
22+
<div class="igx-grid__tbody-content" tabindex="0" [attr.role]="dataView.length ? null : 'row'" (keydown)="navigation.handleNavigation($event)"
2423
(dragStop)="selectionService.dragMode = $event" (scroll)='preventContainerScroll($event)'
2524
(dragScroll)="dragScroll($event)" [igxGridDragSelect]="selectionService.dragMode"
2625
[style.height.px]='totalHeight' [style.width.px]='calcWidth || null' #tbody [attr.aria-activedescendant]="activeDescendant">
@@ -31,7 +30,7 @@
3130
[igxColumnMovingDrop]="headerContainer" [attr.droppable]="true" id="left"
3231
class="igx-grid__scroll-on-drag-pinned" [style.left.px]="pinnedWidth"></span>
3332
<ng-template igxGridFor let-rowData [igxGridForOf]="data
34-
| pivotGridFilter:pivotConfiguration:filterStrategy:advancedFilteringExpressionsTree
33+
| pivotGridFilter:pivotConfiguration:filterStrategy:advancedFilteringExpressionsTree:filteringPipeTrigger:pipeTrigger
3534
| pivotGridRow:pivotConfiguration:expansionStates:pipeTrigger
3635
| pivotGridRowExpansion:pivotConfiguration:expansionStates:pipeTrigger
3736
| pivotGridColumn:pivotConfiguration:expansionStates:pipeTrigger"
@@ -121,4 +120,15 @@
121120
{{columnGroupStates.get(column.field) ? 'expand_more' : 'expand_less'}}</igx-icon>
122121
{{column.header}}
123122
</div>
124-
</ng-template>
123+
</ng-template>
124+
125+
126+
<div [hidden]='true'>
127+
<igx-grid-excel-style-filtering>
128+
<div igxExcelStyleColumnOperations [hidden]='true'>
129+
</div>
130+
<igx-excel-style-filter-operations>
131+
<igx-excel-style-search></igx-excel-style-search>
132+
</igx-excel-style-filter-operations>
133+
</igx-grid-excel-style-filtering>
134+
</div>

0 commit comments

Comments
 (0)