@@ -294,7 +294,10 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
294294 public columnGroupStates = new Map < string , boolean > ( ) ;
295295 public dimensionDataColumns ;
296296 public get pivotKeys ( ) {
297- return this . pivotConfiguration . pivotKeys || { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' } ;
297+ return this . pivotConfiguration . pivotKeys || {
298+ aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' ,
299+ rowDimensionSeparator : '_' , columnDimensionSeparator : '-'
300+ } ;
298301 }
299302 public isPivot = true ;
300303
@@ -309,17 +312,17 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
309312 private p_id = `igx-pivot-grid-${ NEXT_ID ++ } ` ;
310313
311314
312- /**
313- * Gets/Sets the default expand state for all rows.
314- */
315- @Input ( )
316- public get defaultExpandState ( ) {
317- return this . _defaultExpandState ;
318- }
319-
320- public set defaultExpandState ( val : boolean ) {
321- this . _defaultExpandState = val ;
322- }
315+ /**
316+ * Gets/Sets the default expand state for all rows.
317+ */
318+ @Input ( )
319+ public get defaultExpandState ( ) {
320+ return this . _defaultExpandState ;
321+ }
322+
323+ public set defaultExpandState ( val : boolean ) {
324+ this . _defaultExpandState = val ;
325+ }
323326
324327 /**
325328 * @hidden @internal
@@ -577,24 +580,24 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
577580 public getDimensionData ( dim : IPivotDimension ,
578581 dimExprTree : IFilteringExpressionsTree ,
579582 done : ( colVals : any [ ] ) => void ) {
580- let columnValues = [ ] ;
581- const data = this . gridAPI . get_data ( ) ;
582- const state = {
583- expressionsTree : dimExprTree ,
584- strategy : this . filterStrategy || new DimensionValuesFilteringStrategy ( ) ,
585- advancedFilteringExpressionsTree : this . advancedFilteringExpressionsTree
586- } ;
587- const filtered = DataUtil . filter ( data , state , this ) ;
588- const allValuesHierarchy = PivotUtil . getFieldsHierarchy (
589- filtered ,
590- [ dim ] ,
591- PivotDimensionType . Column ,
592- this . pivotKeys
593- ) ;
594- const flatData = Array . from ( allValuesHierarchy . values ( ) ) ;
595- columnValues = flatData . map ( record => this . extractValue ( record [ 'value' ] ) ) ;
596- done ( columnValues ) ;
597- return ;
583+ let columnValues = [ ] ;
584+ const data = this . gridAPI . get_data ( ) ;
585+ const state = {
586+ expressionsTree : dimExprTree ,
587+ strategy : this . filterStrategy || new DimensionValuesFilteringStrategy ( ) ,
588+ advancedFilteringExpressionsTree : this . advancedFilteringExpressionsTree
589+ } ;
590+ const filtered = DataUtil . filter ( data , state , this ) ;
591+ const allValuesHierarchy = PivotUtil . getFieldsHierarchy (
592+ filtered ,
593+ [ dim ] ,
594+ PivotDimensionType . Column ,
595+ this . pivotKeys
596+ ) ;
597+ const flatData = Array . from ( allValuesHierarchy . values ( ) ) ;
598+ columnValues = flatData . map ( record => this . extractValue ( record [ 'value' ] ) ) ;
599+ done ( columnValues ) ;
600+ return ;
598601 }
599602
600603 /** @hidden */
@@ -695,7 +698,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
695698 }
696699
697700 public resolveRowDimensionWidth ( dim : IPivotDimension ) : number {
698- if ( ! dim . width ) {
701+ if ( ! dim . width ) {
699702 return MINIMUM_COLUMN_WIDTH ;
700703 }
701704 const isPercent = dim . width && dim . width . indexOf ( '%' ) !== - 1 ;
@@ -1016,14 +1019,14 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10161019 const rowFields = PivotUtil . flatten ( this . pivotConfiguration . rows ) . map ( x => x . memberName ) ;
10171020 const keyFields = Object . values ( this . pivotKeys ) ;
10181021 const filteredFields = fields . filter ( x => rowFields . indexOf ( x ) === - 1 && keyFields . indexOf ( x ) === - 1 &&
1019- x . indexOf ( '_level ') === - 1 && x . indexOf ( '_records ') === - 1 ) ;
1022+ x . indexOf ( this . pivotKeys . rowDimensionSeparator + 'level ') === - 1 && x . indexOf ( this . pivotKeys . rowDimensionSeparator + 'records ') === - 1 ) ;
10201023 fieldsMap = this . generateFromData ( filteredFields ) ;
10211024 } else {
10221025 fieldsMap = PivotUtil . getFieldsHierarchy (
1023- data ,
1024- this . columnDimensions ,
1025- PivotDimensionType . Column ,
1026- this . pivotKeys
1026+ data ,
1027+ this . columnDimensions ,
1028+ PivotDimensionType . Column ,
1029+ this . pivotKeys
10271030 ) ;
10281031 }
10291032 columns = this . generateColumnHierarchy ( fieldsMap , data ) ;
@@ -1052,17 +1055,18 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10521055 }
10531056
10541057 protected generateFromData ( fields : string [ ] ) {
1055- const dataArr = fields . map ( x => x . split ( '-' ) ) . sort ( x => x . length ) ;
1058+ const separator = this . pivotKeys . columnDimensionSeparator ;
1059+ const dataArr = fields . map ( x => x . split ( separator ) ) . sort ( x => x . length ) ;
10561060 const hierarchy = new Map < string , any > ( ) ;
10571061 dataArr . forEach ( arr => {
10581062 let currentHierarchy = hierarchy ;
10591063 const path = [ ] ;
10601064 for ( const val of arr ) {
10611065 path . push ( val ) ;
1062- let h = currentHierarchy . get ( path . join ( '-' ) ) ;
1066+ let h = currentHierarchy . get ( path . join ( separator ) ) ;
10631067 if ( ! h ) {
1064- currentHierarchy . set ( path . join ( '-' ) , { expandable : true , children : new Map < string , any > ( ) } ) ;
1065- h = currentHierarchy . get ( path . join ( '-' ) ) ;
1068+ currentHierarchy . set ( path . join ( separator ) , { expandable : true , children : new Map < string , any > ( ) , dimension : this . values [ 0 ] } ) ;
1069+ h = currentHierarchy . get ( path . join ( separator ) ) ;
10661070 }
10671071 currentHierarchy = h . children ;
10681072 }
@@ -1101,7 +1105,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
11011105 const ref = this . hasMultipleValues ?
11021106 factoryColumnGroup . create ( this . viewRef . injector ) :
11031107 factoryColumn . create ( this . viewRef . injector ) ;
1104- ref . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
1108+ ref . instance . header = parent != null ? key . split ( parent . header + this . pivotKeys . columnDimensionSeparator ) [ 1 ] : key ;
11051109 ref . instance . field = key ;
11061110 ref . instance . parent = parent ;
11071111 ref . instance . width = value . dimension . width || MINIMUM_COLUMN_WIDTH + 'px' ;
@@ -1121,13 +1125,13 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
11211125 ref . instance . parent = parent ;
11221126 ref . instance . field = key ;
11231127 ref . instance . sortable = true ;
1124- ref . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
1128+ ref . instance . header = parent != null ? key . split ( parent . header + this . pivotKeys . columnDimensionSeparator ) [ 1 ] : key ;
11251129 if ( value . expandable ) {
11261130 ref . instance . headerTemplate = this . headerTemplate ;
11271131 }
11281132 if ( ! this . hasMultipleValues ) {
11291133 const refSibling = factoryColumn . create ( this . viewRef . injector ) ;
1130- refSibling . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
1134+ refSibling . instance . header = parent != null ? key . split ( parent . header + this . pivotKeys . columnDimensionSeparator ) [ 1 ] : key ;
11311135 refSibling . instance . field = key ;
11321136 refSibling . instance . parent = parent ;
11331137 ref . instance . width = value . dimension . width || MINIMUM_COLUMN_WIDTH + 'px' ;
@@ -1165,7 +1169,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
11651169 this . values . forEach ( val => {
11661170 const ref = colFactory . create ( this . viewRef . injector ) ;
11671171 ref . instance . header = val . displayName || val . member ;
1168- ref . instance . field = parent . field + '-' + val . member ;
1172+ ref . instance . field = parent . field + this . pivotKeys . columnDimensionSeparator + val . member ;
11691173 ref . instance . parent = parent ;
11701174 ref . instance . width = isPercent ? width + '%' : width + 'px' ;
11711175 ref . instance . hidden = hidden ;
0 commit comments