@@ -33,7 +33,7 @@ import { IgxForOfSyncService, IgxForOfScrollSyncService } from '../../directives
3333import { GridServiceType , GridType , IGX_GRID_BASE , IGX_GRID_SERVICE_BASE , RowType } from '../common/grid.interface' ;
3434import { IgxGridCRUDService } from '../common/crud.service' ;
3535import { IgxGridSummaryService } from '../summaries/grid-summary.service' ;
36- import { IPivotConfiguration , IPivotDimension , IPivotKeys , PivotDimensionType } from './pivot-grid.interface' ;
36+ import { IDimensionsChange , IPivotConfiguration , IPivotDimension , IPivotKeys , IValuesChange , PivotDimensionType } from './pivot-grid.interface' ;
3737import { IgxPivotHeaderRowComponent } from './pivot-header-row.component' ;
3838import { IgxColumnGroupComponent } from '../columns/column-group.component' ;
3939import { IgxColumnComponent } from '../columns/column.component' ;
@@ -86,6 +86,34 @@ const MINIMUM_COLUMN_WIDTH = 200;
8686export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnInit , AfterContentInit ,
8787 GridType , AfterViewInit {
8888
89+ /**
90+ * Emitted when the dimension collection is changed via the grid chip area.
91+ *
92+ * @remarks
93+ * Returns the new dimension collection and its type:
94+ * @example
95+ * ```html
96+ * <igx-pivot-grid #grid [data]="localData" [height]="'305px'" [autoGenerate]="true"
97+ * (dimensionsChange)="dimensionsChange($event)"></igx-grid>
98+ * ```
99+ */
100+ @Output ( )
101+ public dimensionsChange = new EventEmitter < IDimensionsChange > ( ) ;
102+
103+ /**
104+ * Emitted when the values collection is changed via the grid chip area.
105+ *
106+ * @remarks
107+ * Returns the new dimension
108+ * @example
109+ * ```html
110+ * <igx-pivot-grid #grid [data]="localData" [height]="'305px'" [autoGenerate]="true"
111+ * (valuesChange)="valuesChange($event)"></igx-grid>
112+ * ```
113+ */
114+ @Output ( )
115+ public valuesChange = new EventEmitter < IValuesChange > ( ) ;
116+
89117 /** @hidden @internal */
90118 @ViewChild ( IgxPivotHeaderRowComponent , { static : true } )
91119 public theadRow : IgxPivotHeaderRowComponent ;
@@ -266,7 +294,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
266294
267295 public columnGroupStates = new Map < string , boolean > ( ) ;
268296 public dimensionDataColumns ;
269- public pivotKeys : IPivotKeys = { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' } ;
297+ public pivotKeys : IPivotKeys = { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' } ;
270298 public isPivot = true ;
271299
272300 /**
@@ -429,29 +457,29 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
429457 @Inject ( LOCALE_ID ) localeId : string ,
430458 protected platform : PlatformUtil ,
431459 @Optional ( ) @Inject ( IgxGridTransaction ) protected _diTransactions ?: TransactionService < Transaction , State > ) {
432- super (
433- selectionService ,
434- colResizingService ,
435- gridAPI ,
436- transactionFactory ,
437- elementRef ,
438- zone ,
439- document ,
440- cdr ,
441- resolver ,
442- differs ,
443- viewRef ,
444- appRef ,
445- moduleRef ,
446- factoryResolver ,
447- injector ,
448- navigation ,
449- filteringService ,
450- overlayService ,
451- summaryService ,
452- _displayDensityOptions ,
453- localeId ,
454- platform ) ;
460+ super (
461+ selectionService ,
462+ colResizingService ,
463+ gridAPI ,
464+ transactionFactory ,
465+ elementRef ,
466+ zone ,
467+ document ,
468+ cdr ,
469+ resolver ,
470+ differs ,
471+ viewRef ,
472+ appRef ,
473+ moduleRef ,
474+ factoryResolver ,
475+ injector ,
476+ navigation ,
477+ filteringService ,
478+ overlayService ,
479+ summaryService ,
480+ _displayDensityOptions ,
481+ localeId ,
482+ platform ) ;
455483 }
456484
457485 /**
@@ -504,24 +532,24 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
504532 public getDimensionData ( dim : IPivotDimension ,
505533 dimExprTree : IFilteringExpressionsTree ,
506534 done : ( colVals : any [ ] ) => void ) {
507- let columnValues = [ ] ;
508- const data = this . gridAPI . get_data ( ) ;
509- const state = {
510- expressionsTree : dimExprTree ,
511- strategy : this . filterStrategy || new DimensionValuesFilteringStrategy ( ) ,
512- advancedFilteringExpressionsTree : this . advancedFilteringExpressionsTree
513- } ;
514- const filtered = DataUtil . filter ( data , state , this ) ;
515- const allValuesHierarchy = PivotUtil . getFieldsHierarchy (
516- filtered ,
517- [ dim ] ,
518- PivotDimensionType . Column ,
519- { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
520- ) ;
521- const flatData = Array . from ( allValuesHierarchy . values ( ) ) ;
522- columnValues = flatData . map ( record => this . extractValue ( record [ 'value' ] ) ) ;
523- done ( columnValues ) ;
524- return ;
535+ let columnValues = [ ] ;
536+ const data = this . gridAPI . get_data ( ) ;
537+ const state = {
538+ expressionsTree : dimExprTree ,
539+ strategy : this . filterStrategy || new DimensionValuesFilteringStrategy ( ) ,
540+ advancedFilteringExpressionsTree : this . advancedFilteringExpressionsTree
541+ } ;
542+ const filtered = DataUtil . filter ( data , state , this ) ;
543+ const allValuesHierarchy = PivotUtil . getFieldsHierarchy (
544+ filtered ,
545+ [ dim ] ,
546+ PivotDimensionType . Column ,
547+ { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
548+ ) ;
549+ const flatData = Array . from ( allValuesHierarchy . values ( ) ) ;
550+ columnValues = flatData . map ( record => this . extractValue ( record [ 'value' ] ) ) ;
551+ done ( columnValues ) ;
552+ return ;
525553 }
526554
527555 /** @hidden */
@@ -922,12 +950,12 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
922950 /**
923951 * @hidden
924952 */
925- protected autogenerateColumns ( ) {
926- let columns = [ ] ;
927- const data = this . gridAPI . get_data ( ) ;
928- this . dimensionDataColumns = this . generateDimensionColumns ( ) ;
929- let fieldsMap ;
930- if ( this . pivotConfiguration . columnStrategy && this . pivotConfiguration . columnStrategy instanceof NoopPivotDimensionsStrategy ) {
953+ protected autogenerateColumns ( ) {
954+ let columns = [ ] ;
955+ const data = this . gridAPI . get_data ( ) ;
956+ this . dimensionDataColumns = this . generateDimensionColumns ( ) ;
957+ let fieldsMap ;
958+ if ( this . pivotConfiguration . columnStrategy && this . pivotConfiguration . columnStrategy instanceof NoopPivotDimensionsStrategy ) {
931959 const fields = this . generateDataFields ( data ) ;
932960 const rowFields = PivotUtil . flatten ( this . pivotConfiguration . rows ) . map ( x => x . memberName ) ;
933961 const keyFields = Object . values ( this . pivotKeys ) ;
@@ -936,10 +964,10 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
936964 fieldsMap = this . generateFromData ( filteredFields ) ;
937965 } else {
938966 fieldsMap = PivotUtil . getFieldsHierarchy (
939- data ,
940- this . columnDimensions ,
941- PivotDimensionType . Column ,
942- { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
967+ data ,
968+ this . columnDimensions ,
969+ PivotDimensionType . Column ,
970+ { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
943971 ) ;
944972 }
945973 columns = this . generateColumnHierarchy ( fieldsMap , data ) ;
@@ -1031,7 +1059,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10311059 columns = columns . concat ( measureChildren ) ;
10321060 }
10331061
1034- } else if ( shouldGenerate ) {
1062+ } else if ( shouldGenerate ) {
10351063 const ref = factoryColumnGroup . create ( this . viewRef . injector ) ;
10361064 ref . instance . parent = parent ;
10371065 ref . instance . field = key ;
0 commit comments