@@ -49,10 +49,12 @@ export class IgxPdfExporterService extends IgxBaseExporter {
4949
5050 protected exportDataImplementation ( data : IExportRecord [ ] , options : IgxPdfExporterOptions , done : ( ) => void ) : void {
5151 const firstDataElement = data [ 0 ] ;
52- const _isHierarchicalGrid = firstDataElement ?. type === ExportRecordType . HierarchicalGridRecord ;
52+ const isHierarchicalGrid = firstDataElement ?. type === ExportRecordType . HierarchicalGridRecord ;
5353 const isPivotGrid = firstDataElement ?. type === ExportRecordType . PivotGridRecord ;
5454
55- const defaultOwner = this . _ownersMap . get ( DEFAULT_OWNER ) ;
55+ const defaultOwner = isHierarchicalGrid ?
56+ this . _ownersMap . get ( firstDataElement . owner ) :
57+ this . _ownersMap . get ( DEFAULT_OWNER ) ;
5658
5759 // Get all columns (including multi-column headers)
5860 const allColumns = defaultOwner ?. columns . filter ( col => ! col . skip ) || [ ] ;
@@ -64,17 +66,17 @@ export class IgxPdfExporterService extends IgxBaseExporter {
6466 if ( isPivotGrid && defaultOwner ) {
6567 // First, get PivotRowHeader columns - these are the dimension names (like "City", "ContactTitle")
6668 const pivotRowHeaders = allColumns . filter ( col => col . headerType === ExportHeaderType . PivotRowHeader ) ;
67-
69+
6870 // Get row dimension VALUE columns - these contain the actual data values
6971 const rowHeaderCols = allColumns . filter ( col =>
7072 col . headerType === ExportHeaderType . RowHeader ||
7173 col . headerType === ExportHeaderType . MultiRowHeader ||
7274 col . headerType === ExportHeaderType . PivotMergedHeader
7375 ) ;
74-
76+
7577 // Use PivotRowHeader names as column headers
7678 rowDimensionHeaders . push ( ...pivotRowHeaders . map ( col => col . header || col . field ) . filter ( h => h ) ) ;
77-
79+
7880 // Extract the field names from VALUE columns - these are the keys in the record data
7981 rowDimensionFields . push ( ...rowHeaderCols . map ( col => col . field ) . filter ( f => f ) ) ;
8082 }
@@ -141,16 +143,16 @@ export class IgxPdfExporterService extends IgxBaseExporter {
141143 // Draw multi-level headers if present
142144 if ( hasMultiColumnHeaders || hasMultiRowHeaders ) {
143145 yPosition = this . drawMultiLevelHeaders (
144- pdf ,
145- allColumns ,
146+ pdf ,
147+ allColumns ,
146148 rowDimensionHeaders ,
147- maxLevel ,
149+ maxLevel ,
148150 maxRowLevel ,
149- margin ,
150- yPosition ,
151- columnWidth ,
152- headerHeight ,
153- usableWidth ,
151+ margin ,
152+ yPosition ,
153+ columnWidth ,
154+ headerHeight ,
155+ usableWidth ,
154156 options
155157 ) ;
156158 } else {
@@ -180,16 +182,16 @@ export class IgxPdfExporterService extends IgxBaseExporter {
180182 // Redraw headers on new page
181183 if ( hasMultiColumnHeaders || hasMultiRowHeaders ) {
182184 yPosition = this . drawMultiLevelHeaders (
183- pdf ,
184- allColumns ,
185+ pdf ,
186+ allColumns ,
185187 rowDimensionHeaders ,
186- maxLevel ,
188+ maxLevel ,
187189 maxRowLevel ,
188- margin ,
189- yPosition ,
190- columnWidth ,
191- headerHeight ,
192- usableWidth ,
190+ margin ,
191+ yPosition ,
192+ columnWidth ,
193+ headerHeight ,
194+ usableWidth ,
193195 options
194196 ) ;
195197 } else {
@@ -203,7 +205,7 @@ export class IgxPdfExporterService extends IgxBaseExporter {
203205 // In both cases, the base exporter sets the level property on TreeGridRecord
204206 const isTreeGrid = record . type === 'TreeGridRecord' ;
205207 const recordIsHierarchicalGrid = record . type === 'HierarchicalGridRecord' ;
206-
208+
207209 // For tree grids, indentation is visual (in the first column text)
208210 // For hierarchical grids, we don't use indentation (level determines column offset instead)
209211 const indentLevel = isTreeGrid ? ( record . level || 0 ) : 0 ;
@@ -299,12 +301,12 @@ export class IgxPdfExporterService extends IgxBaseExporter {
299301 if ( maxRowLevel > 0 && rowDimensionHeaders . length > 0 ) {
300302 // Draw background
301303 pdf . setFillColor ( 240 , 240 , 240 ) ;
302-
304+
303305 rowDimensionHeaders . forEach ( ( headerText , index ) => {
304306 const width = baseColumnWidth ;
305307 const height = headerHeight ;
306308 const xPosition = xStart + ( index * baseColumnWidth ) ;
307-
309+
308310 if ( options . showTableBorders ) {
309311 pdf . rect ( xPosition , yPosition , width , height , 'F' ) ;
310312 pdf . rect ( xPosition , yPosition , width , height ) ;
0 commit comments