@@ -919,30 +919,18 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
919
919
const siblingIndex = parentCols . indexOf ( siblingCol ) ;
920
920
if ( currIndex < siblingIndex ) {
921
921
// clicked on the full hierarchy header
922
- const groupColumns = col . children . filter ( x => x . columnGroup ) ;
923
- groupColumns . forEach ( groupColumn => {
924
- groupColumn . hidden = newState ;
925
- this . columnGroupStates . set ( groupColumn . field , newState ) ;
926
- this . resolveToggle ( groupColumn ) ;
927
- } ) ;
928
-
922
+ this . resolveToggle ( col , newState ) ;
929
923
siblingCol . headerTemplate = this . headerTemplate ;
930
924
} else {
931
925
// clicked on summary parent column that contains just the measures
932
926
col . headerTemplate = undefined ;
933
- const groupColumns = siblingCol . children . filter ( x => x . columnGroup ) ;
934
- groupColumns . forEach ( groupColumn => {
935
- groupColumn . hidden = newState ;
936
- this . columnGroupStates . set ( groupColumn . field , newState ) ;
937
- this . resolveToggle ( groupColumn ) ;
938
- } ) ;
927
+ this . resolveToggle ( siblingCol , newState ) ;
939
928
}
940
929
} else {
941
930
const parentCols = col . parent ? col . parent . children : this . columns . filter ( x => x . level === 0 ) ;
942
931
const fieldColumn = parentCols . filter ( x => x . header === col . header && ! x . columnGroup ) [ 0 ] ;
943
932
const groupColumn = parentCols . filter ( x => x . header === col . header && x . columnGroup ) [ 0 ] ;
944
- groupColumn . hidden = newState ;
945
- this . resolveToggle ( groupColumn ) ;
933
+ this . resolveToggle ( groupColumn , newState ) ;
946
934
if ( newState ) {
947
935
fieldColumn . headerTemplate = this . headerTemplate ;
948
936
} else {
@@ -960,12 +948,14 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
960
948
super . setupColumns ( ) ;
961
949
}
962
950
963
- protected resolveToggle ( groupColumn : IgxColumnComponent ) {
951
+ protected resolveToggle ( groupColumn : IgxColumnComponent , state : boolean ) {
964
952
const hasChildGroup = groupColumn . children . filter ( x => x . columnGroup ) . length > 0 ;
953
+ groupColumn . hidden = state ;
954
+ this . columnGroupStates . set ( groupColumn . field , state ) ;
965
955
if ( ! groupColumn . hidden && hasChildGroup ) {
966
956
const groupChildren = groupColumn . children . filter ( x => x . columnGroup ) ;
967
957
groupChildren . forEach ( group => {
968
- this . resolveToggle ( group ) ;
958
+ this . resolveToggle ( group , state ) ;
969
959
} ) ;
970
960
}
971
961
}
0 commit comments