Skip to content

Commit 7e9e94a

Browse files
author
Konstantin Dinev
committed
chore(*): fixing the igx-pivot-grid in the pdf demo
1 parent 03cfc24 commit 7e9e94a

File tree

3 files changed

+50
-13
lines changed

3 files changed

+50
-13
lines changed

src/app/grid-pdf-export/grid-pdf-export.sample.html

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,11 @@ <h3>Pivot Grid (with Aggregated Data)</h3>
128128
</button>
129129
</div>
130130

131-
<igx-pivot-grid #pivotGrid [data]="pivotGridData" [autoGenerate]="false" height="500px" width="100%">
132-
<igx-pivot-configuration>
133-
<igx-pivot-row pivotKeys='["Product", "Region"]'></igx-pivot-row>
134-
<igx-pivot-column pivotKeys='["Quarter"]'></igx-pivot-column>
135-
<igx-pivot-value field="Sales" aggregate="sum" displayName="Total Sales"></igx-pivot-value>
136-
<igx-pivot-value field="Units" aggregate="sum" displayName="Total Units"></igx-pivot-value>
137-
</igx-pivot-configuration>
138-
</igx-pivot-grid>
131+
<div style="display: flex">
132+
<igx-pivot-grid #pivotGrid [data]="pivotGridData" [autoGenerateConfig]="true" height="850px" width="80%">
133+
</igx-pivot-grid>
134+
<igx-pivot-data-selector [grid]="pivotGrid"></igx-pivot-data-selector>
135+
</div>
139136
</div>
140137

141138
<div class="info-section">

src/app/grid-pdf-export/grid-pdf-export.sample.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import {
1515
IgxInputGroupComponent,
1616
IgxLabelDirective,
1717
IgxInputDirective,
18-
IgxColumnGroupComponent
18+
IgxColumnGroupComponent,
19+
IgxPivotGridComponent,
20+
IgxPivotDataSelectorComponent
1921
} from 'igniteui-angular';
2022

2123
@Component({
@@ -28,6 +30,8 @@ import {
2830
IgxColumnGroupComponent,
2931
IgxTreeGridComponent,
3032
IgxHierarchicalGridComponent,
33+
IgxPivotGridComponent,
34+
IgxPivotDataSelectorComponent,
3135
IgxRowIslandComponent,
3236
IgxButtonDirective,
3337
IgxSwitchComponent,
@@ -52,6 +56,9 @@ export class GridPdfExportSampleComponent {
5256
@ViewChild('hierarchicalGrid', { static: true })
5357
public hierarchicalGrid: IgxHierarchicalGridComponent;
5458

59+
@ViewChild('pivotGrid', { static: true })
60+
public pivotGrid: IgxPivotGridComponent;
61+
5562
// Grid data
5663
public gridData = [
5764
{ ID: 1, Name: 'Product A', Category: 'Electronics', Price: 299.99, InStock: true, LaunchDate: new Date(2023, 0, 15) },
@@ -119,6 +126,33 @@ export class GridPdfExportSampleComponent {
119126
}
120127
];
121128

129+
public pivotGridData = [
130+
{
131+
ProductCategory: 'Clothing', UnitPrice: 12.81, SellerName: 'Stanley',
132+
Country: 'Bulgaria', City: 'Sofia', Date: '01/01/2021', UnitsSold: 282
133+
},
134+
{
135+
ProductCategory: 'Clothing', UnitPrice: 49.57, SellerName: 'Elisa',
136+
Country: 'USA', City: 'New York', Date: '01/05/2019', UnitsSold: 296
137+
},
138+
{
139+
ProductCategory: 'Bikes', UnitPrice: 3.56, SellerName: 'Lydia',
140+
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '01/06/2020', UnitsSold: 68
141+
},
142+
{
143+
ProductCategory: 'Accessories', UnitPrice: 85.58, SellerName: 'David',
144+
Country: 'USA', City: 'New York', Date: '04/07/2021', UnitsSold: 293
145+
},
146+
{
147+
ProductCategory: 'Components', UnitPrice: 18.13, SellerName: 'John',
148+
Country: 'USA', City: 'New York', Date: '12/08/2021', UnitsSold: 240
149+
},
150+
{
151+
ProductCategory: 'Clothing', UnitPrice: 68.33, SellerName: 'Larry',
152+
Country: 'Uruguay', City: 'Ciudad de la Costa', Date: '05/12/2020', UnitsSold: 456
153+
}
154+
];
155+
122156
// Export options
123157
public fileName = 'GridExport';
124158
public pageOrientation: 'portrait' | 'landscape' = 'landscape';
@@ -144,6 +178,12 @@ export class GridPdfExportSampleComponent {
144178
this.pdfExporter.export(this.hierarchicalGrid, options);
145179
}
146180

181+
public exportPivotGrid() {
182+
const options = this.createExportOptions();
183+
options.fileName = `PivotGrid_${this.fileName}`;
184+
this.pdfExporter.export(this.pivotGrid, options);
185+
}
186+
147187
private createExportOptions(): IgxPdfExporterOptions {
148188
const options = new IgxPdfExporterOptions(this.fileName);
149189
options.pageOrientation = this.pageOrientation;

src/app/pivot-grid/pivot-grid.sample.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@
7070
[rowSelection]="'single'"
7171
[autoGenerateConfig]="true"
7272
>
73-
<ng-template igxPivotValueChip let-value>
74-
{{ value.displayName }}
75-
</ng-template>
76-
</igx-pivot-grid>
73+
<ng-template igxPivotValueChip let-value>
74+
{{ value.displayName }}
75+
</ng-template>
76+
</igx-pivot-grid>
7777
</div>
7878
<igx-pivot-data-selector [grid]="grid1"></igx-pivot-data-selector>
7979
</div>

0 commit comments

Comments
 (0)