File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed
data-persistence-noop/src
state-persistence-main/src Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -53,11 +53,17 @@ export class Sample {
5353 filters : null
5454 } ;
5555 public stateKey = 'pivot-grid-state' ;
56- private gridState : IgcGridStateComponent ;
56+ private _gridState : IgcGridStateComponent ;
57+
58+ public get gridState ( ) {
59+ if ( ! this . _gridState ) {
60+ this . _gridState = document . getElementById ( 'gridState' ) as IgcGridStateComponent ;
61+ }
62+ return this . _gridState ;
63+ }
5764
5865 constructor ( ) {
5966 var grid = document . getElementById ( "grid" ) as IgcPivotGridComponent ;
60- this . gridState = document . getElementById ( 'gridState' ) as IgcGridStateComponent ;
6167 grid . pivotConfiguration = this . pivotConfiguration ;
6268 PivotNoopData . getData ( ) . then ( ( value ) => {
6369 grid . data = value ;
@@ -69,8 +75,9 @@ export class Sample {
6975 saveStateBtn . addEventListener ( 'click' , ( ev : any ) => this . saveGridState ( ) ) ;
7076 restoreStateBtn . addEventListener ( 'click' , ( ev : any ) => this . restoreGridState ( ) ) ;
7177 clearStorageBtn . addEventListener ( 'click' , ( ev : any ) => this . clearStorage ( ) ) ;
72-
73- this . gridState . addEventListener ( 'stateParsed' , ( ev :any ) => this . stateParsedHandler ( ev ) ) ;
78+ grid . addEventListener ( "rendered" , ( ) => {
79+ this . gridState . addEventListener ( 'stateParsed' , ( ev :any ) => this . stateParsedHandler ( ev ) ) ;
80+ } ) ;
7481 }
7582
7683 public saveGridState ( ) {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ const refreshIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox
1616export class Sample {
1717 private gridData ;
1818 private grid : IgcPivotGridComponent ;
19- private gridState : IgcGridStateComponent ;
19+ private _gridState : IgcGridStateComponent ;
2020 public stateKey = 'pivot-grid-state' ;
2121
2222 public options : IgcGridStateOptions = {
@@ -40,6 +40,13 @@ export class Sample {
4040 return data . map ( ( x : any ) => x . ProductUnitPrice * x . NumberOfUnits ) . reduce ( ( a : any , b : any ) => Math . max ( a , b ) ) ;
4141 } ;
4242
43+ public get gridState ( ) {
44+ if ( ! this . _gridState ) {
45+ this . _gridState = document . getElementById ( 'gridState' ) as IgcGridStateComponent ;
46+ }
47+ return this . _gridState ;
48+ }
49+
4350 private pivotConfiguration : IgcPivotConfiguration = {
4451 columns : [
4552 new IgcPivotDateDimension (
@@ -172,7 +179,6 @@ export class Sample {
172179 constructor ( ) {
173180 var grid = this . grid = document . getElementById ( 'grid' ) as IgcPivotGridComponent ;
174181 this . gridData = new PivotDataFlat ( ) ;
175- this . gridState = document . getElementById ( 'gridState' ) as IgcGridStateComponent ;
176182
177183 var saveStateBtn = document . getElementById ( "saveState" ) as IgcButtonComponent ;
178184 var restoreStateBtn = document . getElementById ( "restoreState" ) as IgcButtonComponent ;
You can’t perform that action at this time.
0 commit comments