Skip to content

Commit 1036177

Browse files
MKirovaMKirova
authored andcommitted
feat(igxPivotGrid): Apply horizontal virtualization per column header level so that each level virtualizes its content individually.
1 parent fea642f commit 1036177

File tree

7 files changed

+46
-12
lines changed

7 files changed

+46
-12
lines changed

projects/igniteui-angular/src/lib/grids/common/grid.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ export interface PivotGridType extends GridType {
638638
dimensionsChange: EventEmitter<IDimensionsChange>;
639639
valuesChange: EventEmitter<IValuesChange>;
640640
pivotKeys: IPivotKeys;
641+
hasMultipleValues: boolean;
641642
}
642643
export interface GridSVGIcon {
643644
name: string;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
11831183
public footer: ElementRef;
11841184

11851185
public get headerContainer() {
1186-
return this.theadRow?.headerContainer;
1186+
return this.theadRow?.headerForOf;
11871187
}
11881188

11891189
public get headerSelectorContainer() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<ng-container *ngTemplateOutlet="column.headerTemplate ? column.headerTemplate : defaultColumn; context: { $implicit: column, column: column}">
6666
</ng-container>
6767
</div>
68-
<div class="igx-grid-thead__group">
68+
<div class="igx-grid-thead__group" *ngIf='!grid.isPivot'>
6969
<ng-container *ngFor="let child of column.children">
7070
<igx-grid-header-group *ngIf="!child.hidden" class="igx-grid-thead__subgroup"
7171
[ngClass]="child.headerGroupClasses"

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ export class IgxGridHeaderRowComponent implements DoCheck {
122122
@ViewChild('headerVirtualContainer', { read: IgxGridForOfDirective, static: true })
123123
public headerContainer: IgxGridForOfDirective<IgxGridHeaderGroupComponent>;
124124

125+
public get headerForOf() {
126+
return this.headerContainer;
127+
}
128+
125129
@ViewChild('headerDragContainer')
126130
public headerDragContainer: ElementRef<HTMLElement>;
127131

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,21 @@
162162
</igx-grid-header-group>
163163
</ng-container>
164164
</ng-container>
165-
166-
<!-- Unpinned columns collection -->
167-
<ng-template igxGridFor #headerVirtualContainer let-column
168-
[igxGridForOf]="unpinnedColumnCollection | igxTopLevel" [igxForScrollContainer]="grid.parentVirtDir"
169-
[igxForContainerSize]="grid.unpinnedWidth" [igxForTrackBy]="grid.trackColumnChanges"
170-
[igxForSizePropName]="'calcPixelWidth'" [igxForScrollOrientation]="'horizontal'">
171-
<igx-grid-header-group [ngClass]="column.headerGroupClasses"
165+
<div>
166+
<div class="igx-grid-thead__group" *ngFor='let dimLevelColumns of columnDimensionsByLevel' [style.width.px]='grid.unpinnedWidth'>
167+
<ng-template igxGridFor #headerVirtualContainer let-column
168+
[igxGridForOf]="dimLevelColumns" [igxForScrollContainer]="grid.parentVirtDir"
169+
[igxForContainerSize]="grid.unpinnedWidth" [igxForTrackBy]="grid.trackColumnChanges"
170+
[igxForSizePropName]="'calcPixelWidth'" [igxForScrollOrientation]="'horizontal'">
171+
<igx-grid-header-group [ngClass]="column.headerGroupClasses"
172172
[ngStyle]="column.headerGroupStyles |igxHeaderGroupStyle:column:grid.pipeTrigger" [column]="column"
173173
[style.min-width]="column.calcWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:hasMRL"
174174
[style.flex-basis]="column.calcWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:hasMRL"
175175
(pointerdown)="grid.navigation.focusOutRowHeader($event)">
176176
</igx-grid-header-group>
177-
</ng-template>
177+
</ng-template>
178+
</div>
179+
</div>
178180

179181
<!-- Pinned columns collection at the end -->
180182
<ng-container *ngIf="pinnedColumnCollection.length && !grid.isPinningToStart">

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ import { IBaseChipEventArgs, IgxChipComponent } from '../../chips/chip.component
1313
import { IgxChipsAreaComponent } from '../../chips/chips-area.component';
1414
import { GridColumnDataType } from '../../data-operations/data-util';
1515
import { SortingDirection } from '../../data-operations/sorting-strategy';
16+
import { IgxGridForOfDirective } from '../../directives/for-of/for_of.directive';
1617
import { ISelectionEventArgs } from '../../drop-down/drop-down.common';
1718
import { IgxDropDownComponent } from '../../drop-down/drop-down.component';
1819
import { AbsoluteScrollStrategy, AutoPositionStrategy, OverlaySettings, PositionSettings, VerticalAlignment } from '../../services/public_api';
1920
import { IGX_GRID_BASE, PivotGridType } from '../common/grid.interface';
21+
import { IgxGridHeaderGroupComponent } from '../headers/grid-header-group.component';
2022
import { IgxGridHeaderRowComponent } from '../headers/grid-header-row.component';
2123
import { DropPosition } from '../moving/moving.service';
2224
import { IgxPivotAggregate, IgxPivotDateAggregate, IgxPivotNumericAggregate, IgxPivotTimeAggregate } from './pivot-grid-aggregate';
2325
import { IPivotAggregator, IPivotDimension, IPivotValue, PivotDimensionType } from './pivot-grid.interface';
26+
import { PivotUtil } from './pivot-util';
2427

2528
/**
2629
*
@@ -61,9 +64,33 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
6164
super(ref, cdr);
6265
}
6366

67+
/** The virtualized part of the header row containing the unpinned header groups. */
68+
@ViewChildren('headerVirtualContainer', { read: IgxGridForOfDirective})
69+
public headerContainers: QueryList<IgxGridForOfDirective<IgxGridHeaderGroupComponent>>;
70+
71+
public get headerForOf() {
72+
return this.headerContainers.last;
73+
}
74+
6475
@ViewChildren('notifyChip')
6576
public notificationChips: QueryList<IgxChipComponent>;
6677

78+
public get columnDimensionsByLevel() {
79+
const res = [];
80+
const columnDimensions = this.grid.columnDimensions;
81+
const cols = this.unpinnedColumnCollection;
82+
let totalDepth = columnDimensions.map(x => PivotUtil.getDimensionDepth(x)).reduce((acc, val) => acc + val) + 1;
83+
if (this.grid.hasMultipleValues) {
84+
totalDepth += 1;
85+
}
86+
for (let i = 0; i < totalDepth; i++) {
87+
const lvl = i;
88+
const colsForLevel = cols.filter(x => x.level === lvl);
89+
res[i] = colsForLevel;
90+
}
91+
return res;
92+
}
93+
6794
public onDimDragStart(event, area) {
6895
this.cdr.detectChanges();
6996
for (let chip of this.notificationChips) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ export class PivotGridSampleComponent {
8888

8989
public pivotConfigHierarchy: IPivotConfiguration = {
9090
columns: [
91-
this.dimensions[0]
91+
this.dimensions[1]
9292
],
9393
rows: [
94-
this.dimensions[1],
94+
this.dimensions[0],
9595
this.dimensions[2]
9696
],
9797
values: [

0 commit comments

Comments
 (0)