Skip to content

Commit 53a0e65

Browse files
committed
feat(pivot-grid): Initial implementaion of Pivot Grid row header resizing
1 parent e59729c commit 53a0e65

11 files changed

+199
-60
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
</igx-circular-bar>
112112
</div>
113113
</ng-template>
114-
<igx-grid-column-resizer *ngIf="colResizingService.showResizer"></igx-grid-column-resizer>
114+
<igx-pivot-grid-column-resizer *ngIf="colResizingService.showResizer"></igx-pivot-grid-column-resizer>
115115
<div class="igx-grid__loading-outlet" #igxLoadingOverlayOutlet igxOverlayOutlet></div>
116116
<div class="igx-grid__outlet" #igxFilteringOverlayOutlet igxOverlayOutlet></div>
117117

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import { DropPosition } from '../moving/moving.service';
5050
import { DimensionValuesFilteringStrategy, NoopPivotDimensionsStrategy } from '../../data-operations/pivot-strategy';
5151
import { IgxGridExcelStyleFilteringComponent } from '../filtering/excel-style/grid.excel-style-filtering.component';
5252
import { IgxPivotGridNavigationService } from './pivot-grid-navigation.service';
53-
import { IgxColumnResizingService } from '../resizing/resizing.service';
53+
import { IgxPivotColumnResizingService } from '../resizing/resizing.service';
5454
import { IgxFlatTransactionFactory, IgxOverlayService, State, Transaction, TransactionService } from '../../services/public_api';
5555
import { DOCUMENT } from '@angular/common';
5656
import { DisplayDensityToken, IDisplayDensityOptions } from '../../core/displayDensity';
@@ -61,6 +61,7 @@ import { IFilteringExpressionsTree } from '../../data-operations/filtering-expre
6161
import { IgxGridTransaction } from '../common/types';
6262
import { SortingDirection } from '../../data-operations/sorting-strategy';
6363
import { GridBaseAPIService } from '../api.service';
64+
import { IgxPivotGridColumnResizerComponent } from '../resizing/resizer.component';
6465

6566
let NEXT_ID = 0;
6667
const MINIMUM_COLUMN_WIDTH = 200;
@@ -77,6 +78,7 @@ const MINIMUM_COLUMN_WIDTH = 200;
7778
{ provide: IGX_GRID_BASE, useExisting: IgxPivotGridComponent },
7879
{ provide: IgxFilteringService, useClass: IgxPivotFilteringService },
7980
IgxPivotGridNavigationService,
81+
IgxPivotColumnResizingService,
8082
IgxForOfSyncService,
8183
IgxForOfScrollSyncService
8284
]
@@ -127,7 +129,14 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
127129
* <igx-pivot-grid [pivotConfiguration]="config"></igx-pivot-grid>
128130
* ```
129131
*/
130-
public pivotConfiguration: IPivotConfiguration = { rows: null, columns: null, values: null, filters: null };
132+
public set pivotConfiguration(value :IPivotConfiguration) {
133+
this._pivotConfiguration = value;
134+
this.notifyChanges(true);
135+
}
136+
137+
public get pivotConfiguration() {
138+
return this._pivotConfiguration;
139+
}
131140

132141
@Input()
133142
/**
@@ -159,6 +168,12 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
159168
@ViewChild('headerTemplate', { read: TemplateRef, static: true })
160169
public headerTemplate: TemplateRef<any>;
161170

171+
/**
172+
* @hidden @internal
173+
*/
174+
@ViewChild(IgxPivotGridColumnResizerComponent)
175+
public resizeLine: IgxPivotGridColumnResizerComponent;
176+
162177
/**
163178
* @hidden @interal
164179
*/
@@ -324,6 +339,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
324339
protected _defaultExpandState = false;
325340
private _data;
326341
private _filteredData;
342+
private _pivotConfiguration: IPivotConfiguration = { rows: null, columns: null, values: null, filters: null };
327343
private p_id = `igx-pivot-grid-${NEXT_ID++}`;
328344

329345

@@ -496,7 +512,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
496512

497513
constructor(
498514
public selectionService: IgxGridSelectionService,
499-
public colResizingService: IgxColumnResizingService,
515+
public colResizingService: IgxPivotColumnResizingService,
500516
gridAPI: GridBaseAPIService<IgxGridBaseDirective & GridType>,
501517
protected transactionFactory: IgxFlatTransactionFactory,
502518
elementRef: ElementRef<HTMLElement>,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@
9898
</igx-pivot-row-dimension-header>
9999
<igx-grid-filtering-cell *ngIf="grid.allowFiltering && grid.filterMode === 'quickFilter'" [column]="column" [attr.draggable]="false"></igx-grid-filtering-cell>
100100
<span *ngIf="!column.columnGroup && column.resizable" class="igx-grid-th__resize-handle"
101-
[igxResizeHandle]="column"
101+
[igxPivotResizeHandle]="column"
102+
[igxPivotResizeHandleHeader]="this"
102103
[attr.draggable]="false"
103104
[style.cursor]="colResizingService.resizeCursor">
104105
</span>

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, HostBinding, HostListener, Inject, Input } from '@angular/core';
1+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, HostBinding, HostListener, Inject, Input, ViewChild } from '@angular/core';
22
import { PlatformUtil } from '../../core/utils';
33
import { IgxColumnComponent } from '../columns/column.component';
44
import { IGX_GRID_BASE, PivotGridType } from '../common/grid.interface';
55
import { IgxFilteringService } from '../filtering/grid-filtering.service';
66
import { IgxGridHeaderGroupComponent } from '../headers/grid-header-group.component';
7-
import { IgxColumnResizingService } from '../resizing/resizing.service';
7+
import { IgxPivotColumnResizingService } from '../resizing/resizing.service';
88
import { IgxRowDirective } from '../row.directive';
99
import { IPivotDimension } from './pivot-grid.interface';
10+
import { IgxPivotRowDimensionHeaderComponent } from './pivot-row-dimension-header.component';
1011

1112
/**
1213
* @hidden
@@ -18,10 +19,16 @@ import { IPivotDimension } from './pivot-grid.interface';
1819
})
1920
export class IgxPivotRowDimensionHeaderGroupComponent extends IgxGridHeaderGroupComponent {
2021

22+
/**
23+
* @hidden
24+
*/
25+
@ViewChild(IgxPivotRowDimensionHeaderComponent)
26+
public header: IgxPivotRowDimensionHeaderComponent;
27+
2128
constructor(private cdRef: ChangeDetectorRef,
2229
@Inject(IGX_GRID_BASE) public grid: PivotGridType,
2330
private elementRef: ElementRef<HTMLElement>,
24-
public colResizingService: IgxColumnResizingService,
31+
public colResizingService: IgxPivotColumnResizingService,
2532
public filteringService: IgxFilteringService,
2633
protected platform: PlatformUtil) {
2734
super(cdRef, grid, elementRef, colResizingService, filteringService, platform);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, Host
33
import { GridType, IGX_GRID_BASE } from '../common/grid.interface';
44

55
import { IgxGridHeaderComponent } from '../headers/grid-header.component';
6-
import { IgxColumnResizingService } from '../resizing/resizing.service';
6+
import { IgxPivotColumnResizingService } from '../resizing/resizing.service';
77

88
/**
99
* @hidden
@@ -17,7 +17,7 @@ export class IgxPivotRowDimensionHeaderComponent extends IgxGridHeaderComponent
1717

1818
constructor(
1919
@Inject(IGX_GRID_BASE) public grid: GridType,
20-
public colResizingService: IgxColumnResizingService,
20+
public colResizingService: IgxPivotColumnResizingService,
2121
public cdr: ChangeDetectorRef,
2222
private refInstance: ElementRef<HTMLElement>
2323
) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export class IgxPivotRowComponent extends IgxRowDirective implements OnChanges {
177177
ref.instance.field = field;
178178
ref.instance.header = header;
179179
ref.instance.width = this.grid.resolveRowDimensionWidth(rootDim) + 'px';
180+
ref.instance.resizable = true;
180181
(ref as any).instance._vIndex = this.grid.columns.length + index + this.index * this.grid.pivotConfiguration.rows.length;
181182
if (dim.childLevel && lvl >= PivotUtil.getTotalLvl(this.data, this.grid.pivotKeys)) {
182183
ref.instance.headerTemplate = this.headerTemplate;

projects/igniteui-angular/src/lib/grids/resizing/resize-handle.directive.ts

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import {
88
OnDestroy
99
} from '@angular/core';
1010
import { Subject, fromEvent } from 'rxjs';
11-
import { debounceTime, takeUntil} from 'rxjs/operators';
11+
import { debounceTime, takeUntil } from 'rxjs/operators';
1212
import { ColumnType } from '../common/grid.interface';
13-
import { IgxColumnResizingService } from './resizing.service';
13+
import { IgxPivotRowDimensionHeaderGroupComponent } from '../pivot-grid/pivot-row-dimension-header-group.component';
14+
import { IgxColumnResizingService, IgxPivotColumnResizingService } from './resizing.service';
1415

1516

1617
/**
@@ -38,9 +39,9 @@ export class IgxResizeHandleDirective implements AfterViewInit, OnDestroy {
3839

3940
private readonly DEBOUNCE_TIME = 200;
4041

41-
constructor(private zone: NgZone,
42-
private element: ElementRef,
43-
public colResizingService: IgxColumnResizingService) { }
42+
constructor(protected zone: NgZone,
43+
protected element: ElementRef,
44+
public colResizingService: IgxColumnResizingService) { }
4445

4546
/**
4647
* @hidden
@@ -56,7 +57,7 @@ export class IgxResizeHandleDirective implements AfterViewInit, OnDestroy {
5657
@HostListener('dblclick')
5758
public onDoubleClick() {
5859
this._dblClick = true;
59-
this.colResizingService.column = this.column;
60+
this.initResizeService();
6061
this.colResizingService.autosizeColumnOnDblClick();
6162
}
6263

@@ -106,12 +107,61 @@ export class IgxResizeHandleDirective implements AfterViewInit, OnDestroy {
106107
* @hidden
107108
*/
108109
private _onResizeAreaMouseDown(event) {
109-
this.colResizingService.column = this.column;
110-
this.colResizingService.isColumnResizing = true;
111-
this.colResizingService.startResizePos = event.clientX;
110+
this.initResizeService(event);
112111

113112
this.colResizingService.showResizer = true;
114113
this.column.grid.cdr.detectChanges();
115114
}
115+
116+
/**
117+
* @hidden
118+
*/
119+
protected initResizeService(event = null) {
120+
this.colResizingService.column = this.column;
121+
122+
if (event) {
123+
this.colResizingService.isColumnResizing = true;
124+
this.colResizingService.startResizePos = event.clientX;
125+
}
126+
}
116127
}
117128

129+
/**
130+
* @hidden
131+
* @internal
132+
*/
133+
@Directive({ selector: '[igxPivotResizeHandle]' })
134+
export class IgxPivotResizeHandleDirective extends IgxResizeHandleDirective {
135+
136+
/**
137+
* @hidden
138+
*/
139+
@Input('igxPivotResizeHandle')
140+
public set pivotColumn(value: ColumnType) {
141+
this.column = value;
142+
};
143+
144+
public get pivotColumn() {
145+
return this.column;
146+
}
147+
148+
/**
149+
* @hidden
150+
*/
151+
@Input('igxPivotResizeHandleHeader')
152+
public rowHeaderGroup: IgxPivotRowDimensionHeaderGroupComponent;
153+
154+
constructor(protected zone: NgZone,
155+
protected element: ElementRef,
156+
public colResizingService: IgxPivotColumnResizingService) {
157+
super(zone, element, colResizingService);
158+
}
159+
160+
/**
161+
* @hidden
162+
*/
163+
protected initResizeService(event = null) {
164+
super.initResizeService(event);
165+
this.colResizingService.rowHeaderGroup = this.rowHeaderGroup;
166+
}
167+
}
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
3-
import { IgxColumnResizingService } from './resizing.service';
4-
import { IgxGridColumnResizerComponent } from './resizer.component';
5-
import { IgxResizeHandleDirective } from './resize-handle.directive';
3+
import { IgxColumnResizingService, IgxPivotColumnResizingService } from './resizing.service';
4+
import { IgxGridColumnResizerComponent, IgxPivotGridColumnResizerComponent } from './resizer.component';
5+
import { IgxPivotResizeHandleDirective, IgxResizeHandleDirective } from './resize-handle.directive';
66
import { IgxColumnResizerDirective } from './resizer.directive';
77

88
export { IgxGridColumnResizerComponent } from './resizer.component';
@@ -13,18 +13,23 @@ export { IgxColumnResizerDirective } from './resizer.directive';
1313
declarations: [
1414
IgxGridColumnResizerComponent,
1515
IgxResizeHandleDirective,
16-
IgxColumnResizerDirective
16+
IgxColumnResizerDirective,
17+
IgxPivotGridColumnResizerComponent,
18+
IgxPivotResizeHandleDirective
1719
],
1820
imports: [
1921
CommonModule
2022
],
2123
exports: [
2224
IgxGridColumnResizerComponent,
2325
IgxResizeHandleDirective,
24-
IgxColumnResizerDirective
26+
IgxColumnResizerDirective,
27+
IgxPivotGridColumnResizerComponent,
28+
IgxPivotResizeHandleDirective
2529
],
2630
providers: [
27-
IgxColumnResizingService
31+
IgxColumnResizingService,
32+
IgxPivotColumnResizingService
2833
]
2934
})
3035
export class IgxGridResizingModule {}

projects/igniteui-angular/src/lib/grids/resizing/resizer.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChangeDetectionStrategy, Component, ViewChild } from '@angular/core';
2-
import { IgxColumnResizingService } from './resizing.service';
2+
import { IgxColumnResizingService, IgxPivotColumnResizingService } from './resizing.service';
33
import { IgxColumnResizerDirective } from './resizer.directive';
44

55
@Component({
@@ -13,3 +13,14 @@ export class IgxGridColumnResizerComponent {
1313

1414
constructor(public colResizingService: IgxColumnResizingService) { }
1515
}
16+
17+
@Component({
18+
changeDetection: ChangeDetectionStrategy.OnPush,
19+
selector: 'igx-pivot-grid-column-resizer',
20+
templateUrl: './resizer.component.html'
21+
})
22+
export class IgxPivotGridColumnResizerComponent extends IgxGridColumnResizerComponent {
23+
constructor(public colResizingService: IgxPivotColumnResizingService) {
24+
super(colResizingService);
25+
}
26+
}

0 commit comments

Comments
 (0)