Skip to content

Commit f0be877

Browse files
Copilotkdinev
andcommitted
Fix PDF export to show actual summary values instead of objects
Updated drawDataRow to properly handle SummaryRecord types: - Detects when record is a SummaryRecord - Extracts label and value/summaryResult from summary objects - Formats as "label: value" similar to Excel export - Falls back to just value if no label present - Prevents "[object Object]" display in PDF exports Co-authored-by: kdinev <[email protected]>
1 parent 64e955a commit f0be877

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,33 @@ export class IgxPdfExporterService extends IgxBaseExporter {
250250
indent: number,
251251
options: IgxPdfExporterOptions
252252
): void {
253+
const isSummaryRecord = record.type === 'SummaryRecord';
254+
253255
columns.forEach((col, index) => {
254256
const xPosition = xStart + (index * columnWidth);
255257
let cellValue = record.data[col.field];
256258

259+
// Handle summary records - cellValue is an IgxSummaryResult object
260+
if (isSummaryRecord && cellValue) {
261+
// For summary records, the cellValue has label and value properties
262+
// or it might be summaryResult property
263+
if (cellValue.label !== undefined || cellValue.value !== undefined) {
264+
const label = cellValue.label?.toString() || '';
265+
const value = cellValue.value?.toString() || cellValue.summaryResult?.toString() || '';
266+
if (label && value) {
267+
cellValue = `${label}: ${value}`;
268+
} else if (label) {
269+
cellValue = label;
270+
} else if (value) {
271+
cellValue = value;
272+
} else {
273+
cellValue = '';
274+
}
275+
} else if (cellValue.summaryResult !== undefined) {
276+
cellValue = cellValue.summaryResult;
277+
}
278+
}
279+
257280
// Convert value to string
258281
if (cellValue === null || cellValue === undefined) {
259282
cellValue = '';

0 commit comments

Comments
 (0)