@@ -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 { IDimensionsChange , IPivotConfiguration , IPivotDimension , IPivotKeys , IValuesChange , PivotDimensionType } from './pivot-grid.interface' ;
36+ import { DEFAULT_PIVOT_KEYS , 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' ;
@@ -294,7 +294,7 @@ 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 || DEFAULT_PIVOT_KEYS ;
298298 }
299299 public isPivot = true ;
300300
@@ -577,24 +577,24 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
577577 public getDimensionData ( dim : IPivotDimension ,
578578 dimExprTree : IFilteringExpressionsTree ,
579579 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 ;
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 ;
598598 }
599599
600600 /** @hidden */
@@ -695,7 +695,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
695695 }
696696
697697 public resolveRowDimensionWidth ( dim : IPivotDimension ) : number {
698- if ( ! dim . width ) {
698+ if ( ! dim . width ) {
699699 return MINIMUM_COLUMN_WIDTH ;
700700 }
701701 const isPercent = dim . width && dim . width . indexOf ( '%' ) !== - 1 ;
@@ -1026,14 +1026,15 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10261026 const rowFields = PivotUtil . flatten ( this . pivotConfiguration . rows ) . map ( x => x . memberName ) ;
10271027 const keyFields = Object . values ( this . pivotKeys ) ;
10281028 const filteredFields = fields . filter ( x => rowFields . indexOf ( x ) === - 1 && keyFields . indexOf ( x ) === - 1 &&
1029- x . indexOf ( '_level' ) === - 1 && x . indexOf ( '_records' ) === - 1 ) ;
1029+ x . indexOf ( this . pivotKeys . rowDimensionSeparator + this . pivotKeys . level ) === - 1 &&
1030+ x . indexOf ( this . pivotKeys . rowDimensionSeparator + this . pivotKeys . records ) === - 1 ) ;
10301031 fieldsMap = this . generateFromData ( filteredFields ) ;
10311032 } else {
10321033 fieldsMap = PivotUtil . getFieldsHierarchy (
1033- data ,
1034- this . columnDimensions ,
1035- PivotDimensionType . Column ,
1036- this . pivotKeys
1034+ data ,
1035+ this . columnDimensions ,
1036+ PivotDimensionType . Column ,
1037+ this . pivotKeys
10371038 ) ;
10381039 }
10391040 columns = this . generateColumnHierarchy ( fieldsMap , data ) ;
@@ -1062,17 +1063,18 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10621063 }
10631064
10641065 protected generateFromData ( fields : string [ ] ) {
1065- const dataArr = fields . map ( x => x . split ( '-' ) ) . sort ( x => x . length ) ;
1066+ const separator = this . pivotKeys . columnDimensionSeparator ;
1067+ const dataArr = fields . map ( x => x . split ( separator ) ) . sort ( x => x . length ) ;
10661068 const hierarchy = new Map < string , any > ( ) ;
10671069 dataArr . forEach ( arr => {
10681070 let currentHierarchy = hierarchy ;
10691071 const path = [ ] ;
10701072 for ( const val of arr ) {
10711073 path . push ( val ) ;
1072- let h = currentHierarchy . get ( path . join ( '-' ) ) ;
1074+ let h = currentHierarchy . get ( path . join ( separator ) ) ;
10731075 if ( ! h ) {
1074- currentHierarchy . set ( path . join ( '-' ) , { expandable : true , children : new Map < string , any > ( ) } ) ;
1075- h = currentHierarchy . get ( path . join ( '-' ) ) ;
1076+ currentHierarchy . set ( path . join ( separator ) , { expandable : true , children : new Map < string , any > ( ) , dimension : this . columnDimensions [ 0 ] } ) ;
1077+ h = currentHierarchy . get ( path . join ( separator ) ) ;
10761078 }
10771079 currentHierarchy = h . children ;
10781080 }
@@ -1111,7 +1113,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
11111113 const ref = this . hasMultipleValues ?
11121114 factoryColumnGroup . create ( this . viewRef . injector ) :
11131115 factoryColumn . create ( this . viewRef . injector ) ;
1114- ref . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
1116+ ref . instance . header = parent != null ? key . split ( parent . header + this . pivotKeys . columnDimensionSeparator ) [ 1 ] : key ;
11151117 ref . instance . field = key ;
11161118 ref . instance . parent = parent ;
11171119 ref . instance . width = value . dimension ?. width || MINIMUM_COLUMN_WIDTH + 'px' ;
@@ -1131,7 +1133,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
11311133 ref . instance . parent = parent ;
11321134 ref . instance . field = key ;
11331135 ref . instance . sortable = true ;
1134- ref . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
1136+ ref . instance . header = parent != null ? key . split ( parent . header + this . pivotKeys . columnDimensionSeparator ) [ 1 ] : key ;
11351137 if ( value . expandable ) {
11361138 ref . instance . headerTemplate = this . headerTemplate ;
11371139 }
@@ -1147,7 +1149,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
11471149 columns = columns . concat ( children ) ;
11481150 if ( value . dimension . childLevel ) {
11491151 const refSibling = factoryColumnGroup . create ( this . viewRef . injector ) ;
1150- refSibling . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
1152+ refSibling . instance . header = parent != null ? key . split ( parent . header + this . pivotKeys . columnDimensionSeparator ) [ 1 ] : key ;
11511153 refSibling . instance . field = key ;
11521154 refSibling . instance . parent = parent ;
11531155 ref . instance . width = value . dimension ?. width || MINIMUM_COLUMN_WIDTH + 'px' ;
@@ -1166,7 +1168,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
11661168 columns = columns . concat ( children ) ;
11671169 if ( value . dimension . childLevel ) {
11681170 const refSibling = factoryColumn . create ( this . viewRef . injector ) ;
1169- refSibling . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
1171+ refSibling . instance . header = parent != null ? key . split ( parent . header + this . pivotKeys . columnDimensionSeparator ) [ 1 ] : key ;
11701172 refSibling . instance . field = key ;
11711173 refSibling . instance . parent = parent ;
11721174 ref . instance . width = value . dimension ?. width || MINIMUM_COLUMN_WIDTH + 'px' ;
@@ -1190,7 +1192,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
11901192 this . values . forEach ( val => {
11911193 const ref = colFactory . create ( this . viewRef . injector ) ;
11921194 ref . instance . header = val . displayName || val . member ;
1193- ref . instance . field = parent . field + '-' + val . member ;
1195+ ref . instance . field = parent . field + this . pivotKeys . columnDimensionSeparator + val . member ;
11941196 ref . instance . parent = parent ;
11951197 ref . instance . width = isPercent ? width + '%' : width + 'px' ;
11961198 ref . instance . hidden = hidden ;
@@ -1203,6 +1205,6 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
12031205 return cols ;
12041206 }
12051207 private extractValue ( value ) {
1206- return value . split ( '-' ) [ value . split ( '-' ) . length - 1 ] ;
1208+ return value . split ( this . pivotKeys . columnDimensionSeparator ) [ value . split ( this . pivotKeys . columnDimensionSeparator ) . length - 1 ] ;
12071209 }
12081210}
0 commit comments