@@ -294,7 +294,10 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
294
294
public columnGroupStates = new Map < string , boolean > ( ) ;
295
295
public dimensionDataColumns ;
296
296
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
+ } ;
298
301
}
299
302
public isPivot = true ;
300
303
@@ -309,17 +312,17 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
309
312
private p_id = `igx-pivot-grid-${ NEXT_ID ++ } ` ;
310
313
311
314
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
+ }
323
326
324
327
/**
325
328
* @hidden @internal
@@ -577,24 +580,24 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
577
580
public getDimensionData ( dim : IPivotDimension ,
578
581
dimExprTree : IFilteringExpressionsTree ,
579
582
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 ;
598
601
}
599
602
600
603
/** @hidden */
@@ -695,7 +698,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
695
698
}
696
699
697
700
public resolveRowDimensionWidth ( dim : IPivotDimension ) : number {
698
- if ( ! dim . width ) {
701
+ if ( ! dim . width ) {
699
702
return MINIMUM_COLUMN_WIDTH ;
700
703
}
701
704
const isPercent = dim . width && dim . width . indexOf ( '%' ) !== - 1 ;
@@ -1016,14 +1019,14 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1016
1019
const rowFields = PivotUtil . flatten ( this . pivotConfiguration . rows ) . map ( x => x . memberName ) ;
1017
1020
const keyFields = Object . values ( this . pivotKeys ) ;
1018
1021
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 ) ;
1020
1023
fieldsMap = this . generateFromData ( filteredFields ) ;
1021
1024
} else {
1022
1025
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
1027
1030
) ;
1028
1031
}
1029
1032
columns = this . generateColumnHierarchy ( fieldsMap , data ) ;
@@ -1052,17 +1055,18 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1052
1055
}
1053
1056
1054
1057
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 ) ;
1056
1060
const hierarchy = new Map < string , any > ( ) ;
1057
1061
dataArr . forEach ( arr => {
1058
1062
let currentHierarchy = hierarchy ;
1059
1063
const path = [ ] ;
1060
1064
for ( const val of arr ) {
1061
1065
path . push ( val ) ;
1062
- let h = currentHierarchy . get ( path . join ( '-' ) ) ;
1066
+ let h = currentHierarchy . get ( path . join ( separator ) ) ;
1063
1067
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 ) ) ;
1066
1070
}
1067
1071
currentHierarchy = h . children ;
1068
1072
}
@@ -1101,7 +1105,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1101
1105
const ref = this . hasMultipleValues ?
1102
1106
factoryColumnGroup . create ( this . viewRef . injector ) :
1103
1107
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 ;
1105
1109
ref . instance . field = key ;
1106
1110
ref . instance . parent = parent ;
1107
1111
ref . instance . width = value . dimension . width || MINIMUM_COLUMN_WIDTH + 'px' ;
@@ -1121,13 +1125,13 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1121
1125
ref . instance . parent = parent ;
1122
1126
ref . instance . field = key ;
1123
1127
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 ;
1125
1129
if ( value . expandable ) {
1126
1130
ref . instance . headerTemplate = this . headerTemplate ;
1127
1131
}
1128
1132
if ( ! this . hasMultipleValues ) {
1129
1133
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 ;
1131
1135
refSibling . instance . field = key ;
1132
1136
refSibling . instance . parent = parent ;
1133
1137
ref . instance . width = value . dimension . width || MINIMUM_COLUMN_WIDTH + 'px' ;
@@ -1165,7 +1169,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1165
1169
this . values . forEach ( val => {
1166
1170
const ref = colFactory . create ( this . viewRef . injector ) ;
1167
1171
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 ;
1169
1173
ref . instance . parent = parent ;
1170
1174
ref . instance . width = isPercent ? width + '%' : width + 'px' ;
1171
1175
ref . instance . hidden = hidden ;
0 commit comments