Skip to content

Commit 6b18e28

Browse files
committed
fix(pivotGrid): Fixes related to auto size of row dimension columns and header sizing fix.
1 parent cdeb976 commit 6b18e28

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
12071207
const isPercent = dim.width && dim.width.indexOf('%') !== -1;
12081208
const isAuto = dim.width && dim.width.indexOf('auto') !== -1;
12091209
if (isPercent) {
1210-
return parseFloat(dim.width) / 100 * this.calcWidth;
1210+
return Math.round(parseFloat(dim.width) / 100 * this.calcWidth);
12111211
} else if (isAuto) {
12121212
return dim.autoWidth;
12131213
} else {
@@ -1613,7 +1613,11 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
16131613
headers.push(dimensionHeader);
16141614
}
16151615
const autoWidth = this.getLargesContentWidth(headers);
1616-
dimension.width = autoWidth;
1616+
if (dimension.width === "auto") {
1617+
dimension.autoWidth = parseFloat(autoWidth);
1618+
} else {
1619+
dimension.width = autoWidth;
1620+
}
16171621
this.pipeTrigger++;
16181622
this.cdr.detectChanges();
16191623
}
@@ -2143,7 +2147,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
21432147
ref.instance.headerTemplate = this.rowDimensionHeaderTemplate;
21442148
ref.instance.resizable = this.rowDimensionResizing;
21452149
ref.instance.sortable = dim.sortable === undefined ? true : dim.sortable;
2146-
ref.instance.width = this.rowDimensionWidthToPixels(dim) + 'px';
2150+
ref.instance.width = this.rowDimensionWidth(dim);
21472151
ref.changeDetectorRef.detectChanges();
21482152
columns.push(ref.instance);
21492153
});
@@ -2162,8 +2166,8 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
21622166

21632167
protected autoSizeDimensionsInView() {
21642168
if (!this.hasDimensionsToAutosize) return;
2165-
for (const dim of this.rowDimensions) {
2166-
if (dim.width === 'auto') {
2169+
for (const dim of this.visibleRowDimensions) {
2170+
if (dim.width === 'auto' && !this.hasHorizontalLayout) {
21672171
const contentWidths = [];
21682172
const relatedDims = PivotUtil.flatten([dim]).map(x => x.memberName);
21692173
const content = this.rowDimensionContentCollection.filter(x => relatedDims.indexOf(x.dimension.memberName) !== -1);
@@ -2176,6 +2180,8 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
21762180
}
21772181
const maxSize = Math.ceil(Math.max(...contentWidths));
21782182
dim.autoWidth = maxSize;
2183+
} else if (dim.width === 'auto') {
2184+
this.autoSizeRowDimension(dim);
21792185
}
21802186
}
21812187
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class IgxPivotRowDimensionContentComponent extends IgxGridHeaderRowCompon
175175
if (this.grid.hasHorizontalLayout) {
176176
return this.width;
177177
}
178-
return this.grid.rowDimensionWidthToPixels(this.rootDimension);
178+
return this.grid.rowDimensionWidth(this.rootDimension);
179179
}
180180

181181
protected extractFromDimensions() {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ export class IgxPivotRowHeaderGroupComponent extends IgxGridHeaderGroupComponent
123123
this.grid.navigation.isRowHeaderActive = false;
124124
return {
125125
row: this.rowIndex, column: this.visibleIndex, level: null,
126-
mchCache: null,
126+
mchCache: {
127+
level: 0,
128+
visibleIndex: this.visibleIndex
129+
},
127130
layout: null
128131
};
129132
}

0 commit comments

Comments
 (0)