@@ -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 /**
@@ -442,29 +470,29 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
442470 @Inject ( LOCALE_ID ) localeId : string ,
443471 protected platform : PlatformUtil ,
444472 @Optional ( ) @Inject ( IgxGridTransaction ) protected _diTransactions ?: TransactionService < Transaction , State > ) {
445- super (
446- selectionService ,
447- colResizingService ,
448- gridAPI ,
449- transactionFactory ,
450- elementRef ,
451- zone ,
452- document ,
453- cdr ,
454- resolver ,
455- differs ,
456- viewRef ,
457- appRef ,
458- moduleRef ,
459- factoryResolver ,
460- injector ,
461- navigation ,
462- filteringService ,
463- overlayService ,
464- summaryService ,
465- _displayDensityOptions ,
466- localeId ,
467- platform ) ;
473+ super (
474+ selectionService ,
475+ colResizingService ,
476+ gridAPI ,
477+ transactionFactory ,
478+ elementRef ,
479+ zone ,
480+ document ,
481+ cdr ,
482+ resolver ,
483+ differs ,
484+ viewRef ,
485+ appRef ,
486+ moduleRef ,
487+ factoryResolver ,
488+ injector ,
489+ navigation ,
490+ filteringService ,
491+ overlayService ,
492+ summaryService ,
493+ _displayDensityOptions ,
494+ localeId ,
495+ platform ) ;
468496 }
469497
470498 /**
@@ -494,6 +522,17 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
494522 } ) ;
495523 }
496524
525+ /**
526+ * Notifies for dimension change.
527+ */
528+ public notifyDimensionChange ( regenerateColumns = false ) {
529+ if ( regenerateColumns ) {
530+ this . setupColumns ( ) ;
531+ }
532+ this . pipeTrigger ++ ;
533+ this . cdr . detectChanges ( ) ;
534+ }
535+
497536 public uniqueDimensionValuesStrategy ( column : IgxColumnComponent , exprTree : IFilteringExpressionsTree ,
498537 done : ( uniqueValues : any [ ] ) => void ) {
499538 const config = this . pivotConfiguration ;
@@ -508,24 +547,24 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
508547 public getDimensionData ( dim : IPivotDimension ,
509548 dimExprTree : IFilteringExpressionsTree ,
510549 done : ( colVals : any [ ] ) => void ) {
511- let columnValues = [ ] ;
512- const data = this . gridAPI . get_data ( ) ;
513- const state = {
514- expressionsTree : dimExprTree ,
515- strategy : this . filterStrategy || new DimensionValuesFilteringStrategy ( ) ,
516- advancedFilteringExpressionsTree : this . advancedFilteringExpressionsTree
517- } ;
518- const filtered = DataUtil . filter ( data , state , this ) ;
519- const allValuesHierarchy = PivotUtil . getFieldsHierarchy (
520- filtered ,
521- [ dim ] ,
522- PivotDimensionType . Column ,
523- { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
524- ) ;
525- const flatData = Array . from ( allValuesHierarchy . values ( ) ) ;
526- columnValues = flatData . map ( record => this . extractValue ( record [ 'value' ] ) ) ;
527- done ( columnValues ) ;
528- return ;
550+ let columnValues = [ ] ;
551+ const data = this . gridAPI . get_data ( ) ;
552+ const state = {
553+ expressionsTree : dimExprTree ,
554+ strategy : this . filterStrategy || new DimensionValuesFilteringStrategy ( ) ,
555+ advancedFilteringExpressionsTree : this . advancedFilteringExpressionsTree
556+ } ;
557+ const filtered = DataUtil . filter ( data , state , this ) ;
558+ const allValuesHierarchy = PivotUtil . getFieldsHierarchy (
559+ filtered ,
560+ [ dim ] ,
561+ PivotDimensionType . Column ,
562+ { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
563+ ) ;
564+ const flatData = Array . from ( allValuesHierarchy . values ( ) ) ;
565+ columnValues = flatData . map ( record => this . extractValue ( record [ 'value' ] ) ) ;
566+ done ( columnValues ) ;
567+ return ;
529568 }
530569
531570 /** @hidden */
@@ -926,12 +965,12 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
926965 /**
927966 * @hidden
928967 */
929- protected autogenerateColumns ( ) {
930- let columns = [ ] ;
931- const data = this . gridAPI . get_data ( ) ;
932- this . dimensionDataColumns = this . generateDimensionColumns ( ) ;
933- let fieldsMap ;
934- if ( this . pivotConfiguration . columnStrategy && this . pivotConfiguration . columnStrategy instanceof NoopPivotDimensionsStrategy ) {
968+ protected autogenerateColumns ( ) {
969+ let columns = [ ] ;
970+ const data = this . gridAPI . get_data ( ) ;
971+ this . dimensionDataColumns = this . generateDimensionColumns ( ) ;
972+ let fieldsMap ;
973+ if ( this . pivotConfiguration . columnStrategy && this . pivotConfiguration . columnStrategy instanceof NoopPivotDimensionsStrategy ) {
935974 const fields = this . generateDataFields ( data ) ;
936975 const rowFields = PivotUtil . flatten ( this . pivotConfiguration . rows ) . map ( x => x . memberName ) ;
937976 const keyFields = Object . values ( this . pivotKeys ) ;
@@ -940,10 +979,10 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
940979 fieldsMap = this . generateFromData ( filteredFields ) ;
941980 } else {
942981 fieldsMap = PivotUtil . getFieldsHierarchy (
943- data ,
944- this . columnDimensions ,
945- PivotDimensionType . Column ,
946- { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
982+ data ,
983+ this . columnDimensions ,
984+ PivotDimensionType . Column ,
985+ { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
947986 ) ;
948987 }
949988 columns = this . generateColumnHierarchy ( fieldsMap , data ) ;
@@ -1035,7 +1074,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10351074 columns = columns . concat ( measureChildren ) ;
10361075 }
10371076
1038- } else if ( shouldGenerate ) {
1077+ } else if ( shouldGenerate ) {
10391078 const ref = factoryColumnGroup . create ( this . viewRef . injector ) ;
10401079 ref . instance . parent = parent ;
10411080 ref . instance . field = key ;
0 commit comments