Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions samples/grids/pivot-grid/data-persistence-noop/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@ export class Sample {
filters: null
};
public stateKey = 'pivot-grid-state';
private gridState: IgcGridStateComponent;
private _gridState: IgcGridStateComponent;

public get gridState() {
if (!this._gridState) {
this._gridState = document.getElementById('gridState') as IgcGridStateComponent;
}
return this._gridState;
}

constructor() {
var grid = document.getElementById("grid") as IgcPivotGridComponent;
this.gridState = document.getElementById('gridState') as IgcGridStateComponent;
grid.pivotConfiguration = this.pivotConfiguration;
PivotNoopData.getData().then((value) => {
grid.data = value;
Expand All @@ -69,8 +75,9 @@ export class Sample {
saveStateBtn.addEventListener('click', (ev: any) => this.saveGridState());
restoreStateBtn.addEventListener('click', (ev: any) => this.restoreGridState());
clearStorageBtn.addEventListener('click', (ev: any) => this.clearStorage());

this.gridState.addEventListener('stateParsed', (ev:any) => this.stateParsedHandler(ev) );
grid.addEventListener("rendered", () => {
this.gridState.addEventListener('stateParsed', (ev:any) => this.stateParsedHandler(ev) );
});
}

public saveGridState() {
Expand Down
10 changes: 8 additions & 2 deletions samples/grids/pivot-grid/state-persistence-main/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const refreshIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox
export class Sample {
private gridData;
private grid: IgcPivotGridComponent;
private gridState: IgcGridStateComponent;
private _gridState: IgcGridStateComponent;
public stateKey = 'pivot-grid-state';

public options: IgcGridStateOptions = {
Expand All @@ -40,6 +40,13 @@ export class Sample {
return data.map((x: any) => x.ProductUnitPrice * x.NumberOfUnits).reduce((a: any, b: any) => Math.max(a,b));
};

public get gridState() {
if (!this._gridState) {
this._gridState = document.getElementById('gridState') as IgcGridStateComponent;
}
return this._gridState;
}

private pivotConfiguration: IgcPivotConfiguration = {
columns: [
new IgcPivotDateDimension(
Expand Down Expand Up @@ -172,7 +179,6 @@ export class Sample {
constructor() {
var grid = this.grid = document.getElementById('grid') as IgcPivotGridComponent;
this.gridData = new PivotDataFlat();
this.gridState = document.getElementById('gridState') as IgcGridStateComponent;

var saveStateBtn = document.getElementById("saveState") as IgcButtonComponent;
var restoreStateBtn = document.getElementById("restoreState") as IgcButtonComponent;
Expand Down
Loading