app.component.html
<ejs-grid id="grid" #grid [dataSource]="data" [allowPaging]="true" [allowSorting]="true"
[filterSettings]="filterSettings"
[allowFiltering]="true" [pageSettings]="pageSettings" (load)="load($event)">
</ejs-grid>
|
app.component.ts
. . .
constructor(
route: ActivatedRoute, @Inject(Router) private router: Router
) {
this.id$ = route.params.pipe(map(p => p.id));
}
ngOnInit() {
this.id$.subscribe(id => {
this.grid.clearFiltering();
this.grid.clearSorting();
setTimeout((e) => {this.updateColumns(id);},10);
this.updateData(id);
const a: any = window.localStorage.getItem('grid' + id);
if (a != null) {
const obj: any = JSON.parse(a);
setTimeout((e) => {
this.grid.setProperties(obj, true);
(this.grid as any).updateColumnObject();
this.grid.refresh();
}, 15); // set the grid state
}
window.onunload = (e) => {
//clearing local storage while unload
window.localStorage.clear();
};
});
this.router.events.subscribe((event: any) => {
if (event instanceof NavigationStart) { //using navigation event to determine the routing event and store the grid settings
if (window.location.pathname === '/grid/1') {
window.localStorage.setItem('grid1', this.grid.getPersistData());
} else {
if (window.location.pathname === '/grid/2') {
window.localStorage.setItem('grid2', this.grid.getPersistData());
}
}
}
});
}
load(e) {
(this.grid as any).updateColumnObject();
}
. . .
}
|
Hi @Tomas
did u find a solution for this problem ?