Skip to content

Commit 25e7c63

Browse files
committed
fix(pdf): add pdf export button
1 parent af110b6 commit 25e7c63

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/app/pivot-grid/pivot-export/pivot-export.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<div class="pivotgrid-sample">
22
<div class="button-container">
3-
<button igxButton="contained" (click)="exportButtonHandler()">Export To Excel</button>
4-
Press the button to export the Pivot Grid as .xlsx file.
3+
<div class="button-container__actions">
4+
<button igxButton="contained" (click)="exportButtonHandler()">Export To Excel</button>
5+
<button igxButton="contained" (click)="exportPdfButtonHandler()">Export To PDF</button>
6+
</div>
57
</div>
68

79
<igx-pivot-grid #grid [data]="data" [pivotConfiguration]="pivotConfig" [rowSelection]="'single'"

src/app/pivot-grid/pivot-export/pivot-export.component.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
height: 80%;
66

77
.button-container {
8-
align-items: flex-start;
98
margin: 25px auto;
9+
10+
&__actions {
11+
display: flex;
12+
flex-direction: row;
13+
gap: 16px;
14+
align-items: center;
15+
}
1016
}
1117

1218
igx-pivot-grid {

src/app/pivot-grid/pivot-export/pivot-export.component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, ViewChild, inject } from "@angular/core";
22

3-
import { IPivotConfiguration, IgxPivotDateDimension, IgxPivotNumericAggregate, PivotAggregation, IgxExcelExporterOptions, IgxExcelExporterService } from 'igniteui-angular/grids/core';
3+
import { IPivotConfiguration, IgxPivotDateDimension, IgxPivotNumericAggregate, PivotAggregation, IgxExcelExporterOptions, IgxExcelExporterService, IgxPdfExporterService, IgxPdfExporterOptions } from 'igniteui-angular/grids/core';
44
import { IgxPivotGridComponent } from 'igniteui-angular/grids/pivot-grid';
55
import { IgxButtonDirective } from 'igniteui-angular/directives';
66
import { SALES_DATA } from "../../data/dataToAnalyze";
@@ -40,9 +40,10 @@ export class IgxTotalSaleAggregate {
4040
})
4141
export class PivotExportComponent {
4242
private excelExportService = inject(IgxExcelExporterService);
43+
private pdfExportService = inject(IgxPdfExporterService);
4344

4445
@ViewChild(IgxPivotGridComponent, { static: true }) public grid: IgxPivotGridComponent;
45-
46+
4647
public data = SALES_DATA;
4748

4849
public pivotConfig: IPivotConfiguration = {
@@ -91,7 +92,7 @@ export class PivotExportComponent {
9192
aggregator: IgxPivotNumericAggregate.sum,
9293
label: 'Sum'
9394
}],
94-
enabled: true,
95+
enabled: false,
9596
formatter: (value) => value ? '$' + parseFloat(value).toFixed(3) : undefined
9697
},
9798
{
@@ -124,4 +125,8 @@ export class PivotExportComponent {
124125
public exportButtonHandler() {
125126
this.excelExportService.export(this.grid, new IgxExcelExporterOptions('ExportedDataFile'));
126127
}
128+
129+
public exportPdfButtonHandler() {
130+
this.pdfExportService.export(this.grid, new IgxPdfExporterOptions('ExportedDataFile'));
131+
}
127132
}

0 commit comments

Comments
 (0)