Skip to content

Commit fbfe628

Browse files
committed
fix(pivotGrid): Update pivot grid correctly on pivotUI settings change.
1 parent 667aadd commit fbfe628

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
357357
*/
358358
public set pivotUI(value: IPivotUISettings) {
359359
this._pivotUI = Object.assign(this._pivotUI, value || {});
360+
this.pipeTrigger++;
361+
this.notifyChanges(true);
360362
}
361363

362364
public get pivotUI() {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<div class="sample-flex-row">
22
<button igxButton="outlined" (click)="saveState()">SAVE STATE</button>
33
<button igxButton="contained" (click)="restoreState()">RESTORE STATE</button>
4+
<button igxButton="contained" (click)="export()">EXPORT</button>
5+
<igx-switch [checked]="pivotUI.showRowHeaders" (change)="onShowHeadersToggle($event)">Show headers</igx-switch>
6+
<igx-switch [checked]="pivotUI.rowLayout === 'horizontal'" (change)="onLayoutToggle($event)">Horizontal layout</igx-switch>
47
<div class="pivot-container">
58
<div>
69
<igx-pivot-grid

src/app/pivot-grid-state/pivot-grid-state.sample.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import {
1414
IgxPivotDataSelectorComponent,
1515
IgxPivotRowDimensionHeaderTemplateDirective,
1616
IPivotUISettings,
17-
PivotRowLayoutType
17+
PivotRowLayoutType,
18+
IgxExcelExporterService,
19+
IgxExcelExporterOptions,
20+
IgxSwitchComponent,
21+
IChangeCheckboxEventArgs
1822
} from 'igniteui-angular';
1923

2024
export class IgxTotalSaleAggregate {
@@ -50,7 +54,7 @@ export class IgxTotalSaleAggregate {
5054
styleUrls: ['pivot-grid-state.sample.scss'],
5155
templateUrl: 'pivot-grid-state.sample.html',
5256
standalone: true,
53-
imports: [FormsModule, IgxButtonDirective,
57+
imports: [FormsModule, IgxButtonDirective, IgxSwitchComponent,
5458
IgxPivotGridComponent, IgxGridStateDirective, IgxPivotDataSelectorComponent, IgxPivotRowDimensionHeaderTemplateDirective ]
5559
})
5660
export class PivotGridStateSampleComponent {
@@ -70,12 +74,6 @@ export class PivotGridStateSampleComponent {
7074
),
7175
],
7276
rows: [
73-
// {
74-
// memberName: 'AllSellers',
75-
// displayName: 'All Sellers',
76-
// memberFunction: () => 'All',
77-
// enabled: true
78-
// },
7977
{
8078
memberName: 'Country',
8179
displayName: 'Country',
@@ -171,6 +169,8 @@ export class PivotGridStateSampleComponent {
171169
@ViewChild(IgxGridStateDirective, { static: true })
172170
public state!: IgxGridStateDirective;
173171

172+
constructor(private exportService: IgxExcelExporterService) {}
173+
174174
public saveState() {
175175
const state = this.state.getState() as string;
176176
window.sessionStorage.setItem('grid-state', state);
@@ -194,5 +194,17 @@ export class PivotGridStateSampleComponent {
194194
}
195195
}
196196

197+
public export() {
198+
this.exportService.export(this.grid1, new IgxExcelExporterOptions('ExportedFile'));
199+
}
197200

201+
public onShowHeadersToggle(event: IChangeCheckboxEventArgs) {
202+
this.pivotUI.showRowHeaders = event.checked;
203+
this.grid1.pivotUI = this.pivotUI;
204+
}
205+
206+
public onLayoutToggle(event: IChangeCheckboxEventArgs) {
207+
this.pivotUI.rowLayout = event.checked ? PivotRowLayoutType.Horizontal : PivotRowLayoutType.Vertical;
208+
this.grid1.pivotUI = this.pivotUI;
209+
}
198210
}

0 commit comments

Comments
 (0)