@@ -82,7 +82,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
8282
8383
8484 public columnGroupStates = new Map < string , boolean > ( ) ;
85- public pivotKeys : IPivotKeys = { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' } ;
85+ public pivotKeys : IPivotKeys = { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' } ;
8686 public isPivot = true ;
8787 protected _defaultExpandState = true ;
8888 private _data ;
@@ -102,11 +102,11 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
102102 * @hidden
103103 */
104104 public ngAfterContentInit ( ) {
105- // ignore any user defined columns and auto-generate based on pivot config.
106- this . columnList . reset ( [ ] ) ;
107- Promise . resolve ( ) . then ( ( ) => {
108- this . setupColumns ( ) ;
109- } ) ;
105+ // ignore any user defined columns and auto-generate based on pivot config.
106+ this . columnList . reset ( [ ] ) ;
107+ Promise . resolve ( ) . then ( ( ) => {
108+ this . setupColumns ( ) ;
109+ } ) ;
110110 }
111111
112112 /** @hidden */
@@ -207,18 +207,18 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
207207 return MINIMUM_COLUMN_WIDTH * rowDimCount ;
208208 }
209209
210- public toggleColumn ( col : IgxColumnComponent ) {
211- const state = this . columnGroupStates . get ( col . field ) ;
212- const newState = ! state ;
213- this . columnGroupStates . set ( col . field , newState ) ;
214- this . toggleGroup ( col , newState ) ;
215- this . reflow ( ) ;
216- }
210+ public toggleColumn ( col : IgxColumnComponent ) {
211+ const state = this . columnGroupStates . get ( col . field ) ;
212+ const newState = ! state ;
213+ this . columnGroupStates . set ( col . field , newState ) ;
214+ this . toggleGroup ( col , newState ) ;
215+ this . reflow ( ) ;
216+ }
217217
218- protected toggleGroup ( col : IgxColumnComponent , newState : boolean ) {
218+ protected toggleGroup ( col : IgxColumnComponent , newState : boolean ) {
219219 if ( this . hasMultipleValues ) {
220- const fieldColumns = col . children . filter ( x => ! x . columnGroup ) ;
221- const groupColumns = col . children . filter ( x => x . columnGroup ) ;
220+ const fieldColumns = col . children . filter ( x => ! x . columnGroup ) ;
221+ const groupColumns = col . children . filter ( x => x . columnGroup ) ;
222222 groupColumns . forEach ( groupColumn => {
223223 groupColumn . hidden = newState ;
224224 this . resolveToggle ( groupColumn ) ;
@@ -228,23 +228,23 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
228228 } ) ;
229229 } else {
230230 const parentCols = col . parent ? col . parent . children : this . columns . filter ( x => x . level === 0 ) ;
231- const fieldColumn = parentCols . filter ( x => x . header === col . header && ! x . columnGroup ) [ 0 ] ;
232- const groupColumn = parentCols . filter ( x => x . header === col . header && x . columnGroup ) [ 0 ] ;
231+ const fieldColumn = parentCols . filter ( x => x . header === col . header && ! x . columnGroup ) [ 0 ] ;
232+ const groupColumn = parentCols . filter ( x => x . header === col . header && x . columnGroup ) [ 0 ] ;
233233 groupColumn . hidden = newState ;
234234 this . resolveToggle ( groupColumn ) ;
235235 fieldColumn . hidden = ! newState ;
236236 if ( newState ) {
237- fieldColumn . headerTemplate = this . headerTemplate ;
237+ fieldColumn . headerTemplate = this . headerTemplate ;
238238 } else {
239- fieldColumn . headerTemplate = undefined ;
239+ fieldColumn . headerTemplate = undefined ;
240240 }
241241 }
242- }
242+ }
243243
244- protected resolveToggle ( groupColumn : IgxColumnComponent ) {
245- const hasChildGroup = groupColumn . children . filter ( x => x . columnGroup ) . length > 0 ;
246- if ( ! groupColumn . hidden && hasChildGroup ) {
247- const fieldChildren = groupColumn . children . filter ( x => ! x . columnGroup ) ;
244+ protected resolveToggle ( groupColumn : IgxColumnComponent ) {
245+ const hasChildGroup = groupColumn . children . filter ( x => x . columnGroup ) . length > 0 ;
246+ if ( ! groupColumn . hidden && hasChildGroup ) {
247+ const fieldChildren = groupColumn . children . filter ( x => ! x . columnGroup ) ;
248248 const groupChildren = groupColumn . children . filter ( x => x . columnGroup ) ;
249249 groupChildren . forEach ( group => {
250250 this . resolveToggle ( group ) ;
@@ -269,26 +269,26 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
269269 /**
270270 * @hidden
271271 */
272- protected autogenerateColumns ( ) {
273- let columns = [ ] ;
274- const data = this . gridAPI . get_data ( ) ;
275- let fieldsMap ;
276- if ( this . pivotConfiguration . columnStrategy && this . pivotConfiguration . columnStrategy instanceof NoopPivotDimensionsStrategy ) {
272+ protected autogenerateColumns ( ) {
273+ let columns = [ ] ;
274+ const data = this . gridAPI . get_data ( ) ;
275+ let fieldsMap ;
276+ if ( this . pivotConfiguration . columnStrategy && this . pivotConfiguration . columnStrategy instanceof NoopPivotDimensionsStrategy ) {
277277 const fields = this . generateDataFields ( data ) ;
278278 const rowFields = PivotUtil . flatten ( this . pivotConfiguration . rows ) . map ( x => x . memberName ) ;
279279 const keyFields = Object . values ( this . pivotKeys ) ;
280280 const filteredFields = fields . filter ( x => rowFields . indexOf ( x ) === - 1 && keyFields . indexOf ( x ) === - 1 &&
281- x . indexOf ( '_level' ) === - 1 && x . indexOf ( '_records' ) === - 1 ) ;
281+ x . indexOf ( '_level' ) === - 1 && x . indexOf ( '_records' ) === - 1 ) ;
282282 fieldsMap = this . generateFromData ( filteredFields ) ;
283- } else {
283+ } else {
284284 fieldsMap = PivotUtil . getFieldsHierarchy (
285- data ,
286- this . pivotConfiguration . columns ,
287- PivotDimensionType . Column ,
288- { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
285+ data ,
286+ this . pivotConfiguration . columns ,
287+ PivotDimensionType . Column ,
288+ { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
289289 ) ;
290- }
291- columns = this . generateColumnHierarchy ( fieldsMap , data ) ;
290+ }
291+ columns = this . generateColumnHierarchy ( fieldsMap , data ) ;
292292 this . _autoGeneratedCols = columns ;
293293
294294 this . columnList . reset ( columns ) ;
@@ -303,11 +303,11 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
303303 dataArr . forEach ( arr => {
304304 let currentHierarchy = hierarchy ;
305305 const path = [ ] ;
306- for ( const val of arr ) {
306+ for ( const val of arr ) {
307307 path . push ( val ) ;
308308 let h = currentHierarchy . get ( path . join ( '-' ) ) ;
309- if ( ! h ) {
310- currentHierarchy . set ( path . join ( '-' ) , { expandable : true , children : new Map < string , any > ( ) } ) ;
309+ if ( ! h ) {
310+ currentHierarchy . set ( path . join ( '-' ) , { expandable : true , children : new Map < string , any > ( ) } ) ;
311311 h = currentHierarchy . get ( path . join ( '-' ) ) ;
312312 }
313313 currentHierarchy = h . children ;
@@ -316,22 +316,22 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
316316 return hierarchy ;
317317 }
318318
319- protected generateColumnHierarchy ( fields : Map < string , any > , data , parent = null ) : IgxColumnComponent [ ] {
319+ protected generateColumnHierarchy ( fields : Map < string , any > , data , parent = null ) : IgxColumnComponent [ ] {
320320 const factoryColumn = this . resolver . resolveComponentFactory ( IgxColumnComponent ) ;
321321 const factoryColumnGroup = this . resolver . resolveComponentFactory ( IgxColumnGroupComponent ) ;
322322 let columns = [ ] ;
323323 fields . forEach ( ( value , key ) => {
324324 if ( value . children == null || value . children . length === 0 || value . children . size === 0 ) {
325325 const ref = this . hasMultipleValues ?
326- factoryColumnGroup . create ( this . viewRef . injector ) :
327- factoryColumn . create ( this . viewRef . injector ) ;
326+ factoryColumnGroup . create ( this . viewRef . injector ) :
327+ factoryColumn . create ( this . viewRef . injector ) ;
328328 ref . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
329329 ref . instance . field = key ;
330330 ref . instance . parent = parent ;
331331 ref . changeDetectorRef . detectChanges ( ) ;
332332 columns . push ( ref . instance ) ;
333333 if ( this . hasMultipleValues ) {
334- const measureChildren = this . getMeasureChildren ( factoryColumn , data , ref . instance , false ) ;
334+ const measureChildren = this . getMeasureChildren ( factoryColumn , data , ref . instance , false ) ;
335335 ref . instance . children . reset ( measureChildren ) ;
336336 columns = columns . concat ( measureChildren ) ;
337337 }
@@ -344,7 +344,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
344344 if ( value . expandable ) {
345345 ref . instance . headerTemplate = this . headerTemplate ;
346346 }
347- if ( ! this . hasMultipleValues ) {
347+ if ( ! this . hasMultipleValues ) {
348348 const refSibling = factoryColumn . create ( this . viewRef . injector ) ;
349349 refSibling . instance . header = parent != null ? key . split ( parent . header + '-' ) [ 1 ] : key ;
350350 refSibling . instance . field = key ;
@@ -358,7 +358,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
358358 ref . changeDetectorRef . detectChanges ( ) ;
359359 columns . push ( ref . instance ) ;
360360 if ( this . hasMultipleValues ) {
361- const measureChildren = this . getMeasureChildren ( factoryColumn , data , ref . instance , true ) ;
361+ const measureChildren = this . getMeasureChildren ( factoryColumn , data , ref . instance , true ) ;
362362 const nestedChildren = filteredChildren . concat ( measureChildren ) ;
363363 const allChildren = children . concat ( measureChildren ) ;
364364 ref . instance . children . reset ( nestedChildren ) ;
@@ -377,7 +377,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
377377 const cols = [ ] ;
378378 this . pivotConfiguration . values . forEach ( val => {
379379 const ref = colFactory . create ( this . viewRef . injector ) ;
380- ref . instance . header = val . member ;
380+ ref . instance . header = val . displayName || val . member ;
381381 ref . instance . field = parent . field + '-' + val . member ;
382382 ref . instance . parent = parent ;
383383 ref . instance . hidden = hidden ;
0 commit comments