Skip to content

Commit 9a54a80

Browse files
MKirovaMKirova
authored andcommitted
Change default expand state to be collapsed. Allow setting it via Input.
1 parent 3cff889 commit 9a54a80

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
| pivotGridRow:pivotConfiguration:expansionStates:pipeTrigger:sortingExpressions
3636
| pivotGridColumn:pivotConfiguration:expansionStates:pipeTrigger:sortingExpressions
3737
| pivotGridColumnSort:sortingExpressions:sortStrategy:pipeTrigger
38-
| pivotGridRowExpansion:pivotConfiguration:expansionStates:pipeTrigger"
38+
| pivotGridRowExpansion:pivotConfiguration:expansionStates:defaultExpandState:pipeTrigger"
3939
let-rowIndex="index" [igxForScrollOrientation]="'vertical'" [igxForScrollContainer]='verticalScroll'
4040
[igxForContainerSize]='calcHeight'
4141
[igxForItemSize]="hasColumnLayouts ? rowHeight * multiRowLayoutRowSize + 1 : renderedRowHeight"

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,24 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
274274
*/
275275
public dragRowID = null;
276276

277-
protected _defaultExpandState = true;
277+
protected _defaultExpandState = false;
278278
private _data;
279279
private _filteredData;
280280
private p_id = `igx-pivot-grid-${NEXT_ID++}`;
281281

282+
283+
/**
284+
* Gets/Sets the default expand state for all rows.
285+
*/
286+
@Input()
287+
public get defaultExpandState() {
288+
return this._defaultExpandState;
289+
}
290+
291+
public set defaultExpandState(val: boolean) {
292+
this._defaultExpandState = val;
293+
}
294+
282295
/**
283296
* @hidden @internal
284297
*/

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class IgxPivotRowExpansionPipe implements PipeTransform {
5454
collection: any[],
5555
config: IPivotConfiguration,
5656
expansionStates: Map<any, boolean>,
57+
defaultExpand: boolean,
5758
_pipeTrigger?: number,
5859
__?,
5960
pivotKeys: IPivotKeys = { aggregations: 'aggregations', records: 'records', children: 'children', level: 'level' }
@@ -65,7 +66,7 @@ export class IgxPivotRowExpansionPipe implements PipeTransform {
6566
for (const row of enabledRows) {
6667
const lvl = PivotUtil.getDimensionDepth(row);
6768
totalLlv += lvl;
68-
PivotUtil.flattenHierarchy(data, config, row, expansionStates, pivotKeys, totalLlv, prevDims, 0);
69+
PivotUtil.flattenHierarchy(data, config, row, expansionStates, defaultExpand, pivotKeys, totalLlv, prevDims, 0);
6970
prevDims.push(row);
7071
}
7172
this.cleanState(data, pivotKeys);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ export class PivotUtil {
6666
config: IPivotConfiguration,
6767
dim: IPivotDimension,
6868
expansionStates: any,
69+
defaultExpandState: boolean,
6970
pivotKeys: IPivotKeys,
7071
lvl: number,
7172
prevDims: IPivotDimension[],
7273
currDimLvl: number) {
7374
const data = records;
74-
const defaultExpandState = true;
7575
for (let i = 0; i < data.length; i++) {
7676
const rec = data[i];
7777
const field = dim.memberName;
@@ -90,7 +90,7 @@ export class PivotUtil {
9090
if (dim.childLevel) {
9191
if (PivotUtil.getDimensionDepth(dim) > 1) {
9292
dimData = this.flattenHierarchy(dimData, config, dim.childLevel,
93-
expansionStates, pivotKeys, lvl - 1, prevDims, currDimLvl + 1);
93+
expansionStates, defaultExpandState, pivotKeys, lvl - 1, prevDims, currDimLvl + 1);
9494
} else {
9595
dimData.forEach(d => {
9696
d[dim.childLevel.memberName + '_' + pivotKeys.level] = currDimLvl + 1;

0 commit comments

Comments
 (0)