Skip to content

Commit 9761c2e

Browse files
MKirovaMKirova
authored andcommitted
Simplify handling a bit.
1 parent e4136eb commit 9761c2e

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -919,30 +919,18 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
919919
const siblingIndex = parentCols.indexOf(siblingCol);
920920
if (currIndex < siblingIndex) {
921921
// 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);
929923
siblingCol.headerTemplate = this.headerTemplate;
930924
} else {
931925
// clicked on summary parent column that contains just the measures
932926
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);
939928
}
940929
} else {
941930
const parentCols = col.parent ? col.parent.children : this.columns.filter(x => x.level === 0);
942931
const fieldColumn = parentCols.filter(x => x.header === col.header && !x.columnGroup)[0];
943932
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);
946934
if (newState) {
947935
fieldColumn.headerTemplate = this.headerTemplate;
948936
} else {
@@ -960,12 +948,14 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
960948
super.setupColumns();
961949
}
962950

963-
protected resolveToggle(groupColumn: IgxColumnComponent) {
951+
protected resolveToggle(groupColumn: IgxColumnComponent, state: boolean) {
964952
const hasChildGroup = groupColumn.children.filter(x => x.columnGroup).length > 0;
953+
groupColumn.hidden = state;
954+
this.columnGroupStates.set(groupColumn.field, state);
965955
if (!groupColumn.hidden && hasChildGroup) {
966956
const groupChildren = groupColumn.children.filter(x => x.columnGroup);
967957
groupChildren.forEach(group => {
968-
this.resolveToggle(group);
958+
this.resolveToggle(group, state);
969959
});
970960
}
971961
}

0 commit comments

Comments
 (0)