Skip to content

Commit 995a4b8

Browse files
committed
fix(PDF): Export inner grids' multi-column headers
1 parent 42a6864 commit 995a4b8

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

projects/igniteui-angular/src/lib/services/pdf/pdf-exporter.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,11 @@ export class IgxPdfExporterService extends IgxBaseExporter {
373373
}
374374

375375
// Draw each header in this level
376-
headersForLevel.forEach((col) => {
376+
headersForLevel.forEach((col, idx) => {
377377
const colSpan = col.columnSpan || 1;
378378
const width = baseColumnWidth * colSpan;
379-
const xPosition = xStart + rowDimensionOffset + (col.startIndex * baseColumnWidth);
379+
const startIndex = col.startIndex !== -1 ? col.startIndex : idx;
380+
const xPosition = xStart + rowDimensionOffset + (startIndex * baseColumnWidth);
380381

381382
if (options.showTableBorders) {
382383
pdf.rect(xPosition, yPosition, width, headerHeight);
@@ -455,8 +456,27 @@ export class IgxPdfExporterService extends IgxBaseExporter {
455456
}
456457

457458
// Draw child table headers
458-
this.drawTableHeaders(pdf, childColumns, [], childTableX, yPosition, childColumnWidth, headerHeight, childTableWidth, options);
459-
yPosition += headerHeight;
459+
const childOwnerObj = this._ownersMap.get(childOwner);
460+
const hasMultiColumnHeaders = childOwnerObj?.maxLevel > 0 && childOwnerObj.columns.some(col => col.headerType === ExportHeaderType.MultiColumnHeader);
461+
462+
if (hasMultiColumnHeaders) {
463+
yPosition = this.drawMultiLevelHeaders(
464+
pdf,
465+
childOwnerObj.columns,
466+
[], // rowDimensionHeaders, if any
467+
childOwnerObj.maxLevel,
468+
0, // maxRowLevel
469+
childTableX,
470+
yPosition,
471+
childColumnWidth,
472+
headerHeight,
473+
childTableWidth,
474+
options
475+
);
476+
} else {
477+
this.drawTableHeaders(pdf, childColumns, [], childTableX, yPosition, childColumnWidth, headerHeight, childTableWidth, options);
478+
yPosition += headerHeight;
479+
}
460480

461481
// Find the minimum level in these records (direct children of parent)
462482
const minLevel = Math.min(...dataRecords.map(r => r.level));

0 commit comments

Comments
 (0)