@@ -1599,14 +1599,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1599
1599
public autoSizeRowDimension ( dimension : IPivotDimension ) {
1600
1600
if ( this . getDimensionType ( dimension ) === PivotDimensionType . Row ) {
1601
1601
const relatedDims : string [ ] = PivotUtil . flatten ( [ dimension ] ) . map ( ( x : IPivotDimension ) => x . memberName ) ;
1602
- let contentCollection = [ ] ;
1603
- if ( this . hasHorizontalLayout ) {
1604
- const allMrlContents = this . rowDimensionMrlRowsCollection . map ( mrlRow => mrlRow . contentCells . toArray ( ) ) . flat ( ) ;
1605
- contentCollection = allMrlContents . filter ( cell => cell . rootDimension === dimension ) ;
1606
- } else {
1607
- contentCollection = this . rowDimensionContentCollection . toArray ( ) ;
1608
- }
1609
-
1602
+ const contentCollection = this . getContentCollection ( dimension ) ;
1610
1603
const content = contentCollection . filter ( x => relatedDims . indexOf ( x . dimension . memberName ) !== - 1 ) ;
1611
1604
const headers = content . map ( x => x . headerGroups . toArray ( ) ) . flat ( ) . map ( x => x . header && x . header . refInstance ) ;
1612
1605
if ( this . pivotUI . showRowHeaders ) {
@@ -1950,10 +1943,8 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1950
1943
}
1951
1944
1952
1945
protected getPivotRowHeaderContentWidth ( headerGroup : IgxPivotRowHeaderGroupComponent ) {
1953
- const headerStyle = this . document . defaultView . getComputedStyle ( headerGroup . header . refInstance . nativeElement ) ;
1954
- const headerPadding = parseFloat ( headerStyle . paddingLeft ) + parseFloat ( headerStyle . paddingRight ) +
1955
- parseFloat ( headerStyle . borderRightWidth ) ;
1956
- return this . getHeaderCellWidth ( headerGroup . header . refInstance . nativeElement ) . width + headerPadding ;
1946
+ const headerSizes = this . getHeaderCellWidth ( headerGroup . header . refInstance . nativeElement ) ;
1947
+ return headerSizes . width + headerSizes . padding ;
1957
1948
}
1958
1949
1959
1950
protected getLargesContentWidth ( contents : ElementRef [ ] ) : string {
@@ -2160,29 +2151,45 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
2160
2151
if ( this . hasDimensionsToAutosize ) {
2161
2152
this . cdr . detectChanges ( ) ;
2162
2153
this . zone . onStable . pipe ( first ( ) ) . subscribe ( ( ) => {
2163
- this . autoSizeDimensionsInView ( ) ;
2154
+ requestAnimationFrame ( ( ) => {
2155
+ this . autoSizeDimensionsInView ( ) ;
2156
+ } ) ;
2164
2157
} ) ;
2165
2158
}
2166
2159
}
2167
2160
2161
+ protected getContentCollection ( dimenstion : IPivotDimension ) {
2162
+ let contentCollection ;
2163
+ if ( this . hasHorizontalLayout ) {
2164
+ const allMrlContents = this . rowDimensionMrlRowsCollection . map ( mrlRow => mrlRow . contentCells . toArray ( ) ) . flat ( ) ;
2165
+ contentCollection = allMrlContents . filter ( cell => cell . rootDimension === dimenstion ) ;
2166
+ } else {
2167
+ contentCollection = this . rowDimensionContentCollection . toArray ( ) ;
2168
+ }
2169
+ return contentCollection ;
2170
+ }
2171
+
2168
2172
protected autoSizeDimensionsInView ( ) {
2169
2173
if ( ! this . hasDimensionsToAutosize ) return ;
2170
2174
for ( const dim of this . visibleRowDimensions ) {
2171
- if ( dim . width === 'auto' && ! this . hasHorizontalLayout ) {
2175
+ if ( dim . width === 'auto' ) {
2172
2176
const contentWidths = [ ] ;
2173
2177
const relatedDims = PivotUtil . flatten ( [ dim ] ) . map ( x => x . memberName ) ;
2174
- const content = this . rowDimensionContentCollection . filter ( x => relatedDims . indexOf ( x . dimension . memberName ) !== - 1 ) ;
2178
+ const contentCollection = this . getContentCollection ( dim ) ;
2179
+ const content = contentCollection . filter ( x => relatedDims . indexOf ( x . dimension . memberName ) !== - 1 ) ;
2175
2180
const headers = content . map ( x => x . headerGroups . toArray ( ) ) . flat ( ) . map ( x => x . header && x . header . refInstance ) ;
2176
2181
headers . forEach ( ( header ) => contentWidths . push ( header ?. nativeElement ?. offsetWidth || 0 ) ) ;
2182
+ if ( this . pivotUI . showRowHeaders ) {
2183
+ const dimensionHeader = this . theadRow . rowDimensionHeaders . find ( x => x . column . field === dim . memberName ) ;
2184
+ contentWidths . push ( parseFloat ( this . getLargesContentWidth ( [ dimensionHeader ] ) ) ) ;
2185
+ }
2177
2186
const max = Math . max ( ...contentWidths ) ;
2178
2187
if ( max === 0 ) {
2179
2188
// cells not in DOM yet...
2180
2189
continue ;
2181
2190
}
2182
2191
const maxSize = Math . ceil ( Math . max ( ...contentWidths ) ) ;
2183
2192
dim . autoWidth = maxSize ;
2184
- } else if ( dim . width === 'auto' ) {
2185
- this . autoSizeRowDimension ( dim ) ;
2186
2193
}
2187
2194
}
2188
2195
}
0 commit comments