@@ -64,10 +64,17 @@ export class IgxPdfExporterService extends IgxBaseExporter {
6464 const rowDimensionFields : string [ ] = [ ] ;
6565 const rowDimensionHeaders : string [ ] = [ ] ;
6666 if ( isPivotGrid && defaultOwner ) {
67+ const uniqueFields = new Set < string > ( ) ;
68+
6769 // Primary source: use dimensionKeys from the first record (set by base exporter)
6870 // This is the authoritative source for dimension field names
6971 if ( firstDataElement ?. dimensionKeys && Array . isArray ( firstDataElement . dimensionKeys ) && firstDataElement . dimensionKeys . length > 0 ) {
70- rowDimensionFields . push ( ...firstDataElement . dimensionKeys ) ;
72+ firstDataElement . dimensionKeys . forEach ( key => {
73+ if ( ! uniqueFields . has ( key ) ) {
74+ uniqueFields . add ( key ) ;
75+ rowDimensionFields . push ( key ) ;
76+ }
77+ } ) ;
7178 }
7279
7380 // If we still don't have fields, try to get them from the record data
@@ -83,7 +90,6 @@ export class IgxPdfExporterService extends IgxBaseExporter {
8390
8491 const recordKeys = Object . keys ( firstDataElement . data ) ;
8592 // Try to match row dimension columns to record keys
86- const uniqueFields = new Set < string > ( ) ;
8793 rowHeaderCols . forEach ( col => {
8894 const fieldName = typeof col . field === 'string' ? col . field : null ;
8995 const columnGroup = typeof col . columnGroup === 'string' ? col . columnGroup :
@@ -108,7 +114,12 @@ export class IgxPdfExporterService extends IgxBaseExporter {
108114 key === key . trim ( ) ;
109115 } ) ;
110116 // Take up to the number of row dimensions (usually 1-3)
111- rowDimensionFields . push ( ...simpleKeys . slice ( 0 , Math . min ( 3 , simpleKeys . length ) ) ) ;
117+ simpleKeys . slice ( 0 , Math . min ( 3 , simpleKeys . length ) ) . forEach ( key => {
118+ if ( ! uniqueFields . has ( key ) ) {
119+ uniqueFields . add ( key ) ;
120+ rowDimensionFields . push ( key ) ;
121+ }
122+ } ) ;
112123 }
113124 }
114125
0 commit comments