11import {
22 AfterContentInit ,
33 ChangeDetectionStrategy ,
4+ ChangeDetectorRef ,
45 Component ,
6+ ComponentFactoryResolver ,
7+ ElementRef ,
58 forwardRef ,
69 HostBinding ,
10+ Inject ,
711 Input ,
12+ IterableDiffers ,
13+ LOCALE_ID ,
14+ NgZone ,
815 OnInit ,
16+ Optional ,
17+ QueryList ,
918 TemplateRef ,
10- ViewChild
19+ ViewChild ,
20+ ViewChildren ,
21+ ViewContainerRef
1122} from '@angular/core' ;
1223import { IgxGridBaseDirective } from '../grid-base.directive' ;
1324import { GridBaseAPIService } from '../api.service' ;
@@ -24,6 +35,14 @@ import { IgxColumnGroupComponent } from '../columns/column-group.component';
2435import { IgxColumnComponent } from '../columns/column.component' ;
2536import { PivotUtil } from './pivot-util' ;
2637import { NoopPivotDimensionsStrategy } from '../../data-operations/pivot-strategy' ;
38+ import { IgxGridExcelStyleFilteringComponent } from '../filtering/excel-style/grid.excel-style-filtering.component' ;
39+ import { IgxPivotGridNavigationService } from './pivot-grid-navigation.service' ;
40+ import { IgxColumnResizingService } from '../resizing/resizing.service' ;
41+ import { IgxFlatTransactionFactory , IgxOverlayService , State , Transaction , TransactionService } from '../../services/public_api' ;
42+ import { DOCUMENT } from '@angular/common' ;
43+ import { DisplayDensityToken , IDisplayDensityOptions } from '../../core/displayDensity' ;
44+ import { PlatformUtil } from '../../core/utils' ;
45+ import { IgxGridTransaction } from '../hierarchical-grid/public_api' ;
2746
2847let NEXT_ID = 0 ;
2948const MINIMUM_COLUMN_WIDTH = 200 ;
@@ -39,7 +58,7 @@ const MINIMUM_COLUMN_WIDTH = 200;
3958 GridBaseAPIService ,
4059 { provide : IgxGridBaseDirective , useExisting : forwardRef ( ( ) => IgxPivotGridComponent ) } ,
4160 IgxFilteringService ,
42- IgxGridNavigationService ,
61+ IgxPivotGridNavigationService ,
4362 IgxForOfSyncService ,
4463 IgxForOfScrollSyncService
4564 ]
@@ -51,6 +70,8 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
5170 @ViewChild ( IgxPivotHeaderRowComponent , { static : true } )
5271 public theadRow : IgxPivotHeaderRowComponent ;
5372
73+
74+
5475 @Input ( )
5576 /**
5677 * Gets/Sets the pivot configuration with all related dimensions and values.
@@ -80,15 +101,64 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
80101 @ViewChild ( 'headerTemplate' , { read : TemplateRef , static : true } )
81102 public headerTemplate : TemplateRef < any > ;
82103
104+ /**
105+ * @hidden @internal
106+ */
107+ @ViewChildren ( IgxGridExcelStyleFilteringComponent , { read : IgxGridExcelStyleFilteringComponent } )
108+ public excelStyleFilteringComponents : QueryList < IgxGridExcelStyleFilteringComponent > ;
109+
83110
84111 public columnGroupStates = new Map < string , boolean > ( ) ;
112+ public originalDataColumns ;
85113 public pivotKeys : IPivotKeys = { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' } ;
86114 public isPivot = true ;
87115 protected _defaultExpandState = true ;
88116 private _data ;
89117 private _filteredData ;
90118 private p_id = `igx-pivot-grid-${ NEXT_ID ++ } ` ;
91119
120+
121+ constructor (
122+ public selectionService : IgxGridSelectionService ,
123+ public colResizingService : IgxColumnResizingService ,
124+ gridAPI : GridBaseAPIService < IgxGridBaseDirective & GridType > ,
125+ protected transactionFactory : IgxFlatTransactionFactory ,
126+ elementRef : ElementRef ,
127+ zone : NgZone ,
128+ @Inject ( DOCUMENT ) public document ,
129+ cdr : ChangeDetectorRef ,
130+ resolver : ComponentFactoryResolver ,
131+ differs : IterableDiffers ,
132+ viewRef : ViewContainerRef ,
133+ navigation : IgxPivotGridNavigationService ,
134+ filteringService : IgxFilteringService ,
135+ @Inject ( IgxOverlayService ) protected overlayService : IgxOverlayService ,
136+ public summaryService : IgxGridSummaryService ,
137+ @Optional ( ) @Inject ( DisplayDensityToken ) protected _displayDensityOptions : IDisplayDensityOptions ,
138+ @Inject ( LOCALE_ID ) localeId : string ,
139+ protected platform : PlatformUtil ,
140+ @Optional ( ) @Inject ( IgxGridTransaction ) protected _diTransactions ?: TransactionService < Transaction , State > ) {
141+ super (
142+ selectionService ,
143+ colResizingService ,
144+ gridAPI ,
145+ transactionFactory ,
146+ elementRef ,
147+ zone ,
148+ document ,
149+ cdr ,
150+ resolver ,
151+ differs ,
152+ viewRef ,
153+ navigation ,
154+ filteringService ,
155+ overlayService ,
156+ summaryService ,
157+ _displayDensityOptions ,
158+ localeId ,
159+ platform ) ;
160+ }
161+
92162 /**
93163 * @hidden
94164 */
@@ -288,6 +358,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
288358 protected autogenerateColumns ( ) {
289359 let columns = [ ] ;
290360 const data = this . gridAPI . get_data ( ) ;
361+ this . originalDataColumns = this . generateOriginalColumns ( ) ;
291362 let fieldsMap ;
292363 if ( this . pivotConfiguration . columnStrategy && this . pivotConfiguration . columnStrategy instanceof NoopPivotDimensionsStrategy ) {
293364 const fields = this . generateDataFields ( data ) ;
@@ -313,6 +384,21 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
313384 }
314385 }
315386
387+ protected generateOriginalColumns ( ) {
388+ const data = this . gridAPI . get_data ( ) ;
389+ const fields = this . generateDataFields ( data ) ;
390+ const columns = [ ] ;
391+ const factory = this . resolver . resolveComponentFactory ( IgxColumnComponent ) ;
392+ fields . forEach ( ( field ) => {
393+ const ref = factory . create ( this . viewRef . injector ) ;
394+ ref . instance . field = field ;
395+ ref . instance . dataType = this . resolveDataTypes ( data [ 0 ] [ field ] ) ;
396+ ref . changeDetectorRef . detectChanges ( ) ;
397+ columns . push ( ref . instance ) ;
398+ } ) ;
399+ return columns ;
400+ }
401+
316402 protected generateFromData ( fields : string [ ] ) {
317403 const dataArr = fields . map ( x => x . split ( '-' ) ) . sort ( x => x . length ) ;
318404 const hierarchy = new Map < string , any > ( ) ;
0 commit comments