Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit b994f2c

Browse files
Ghislain BeaulacGhislain Beaulac
authored andcommitted
fix an issue caused by leftover filter, now watch for route change and destroy the grid & clear filter when that happens
1 parent 83eaeac commit b994f2c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import 'slickgrid/plugins/slick.headermenu';
2020
import 'slickgrid/plugins/slick.rowmovemanager';
2121
import 'slickgrid/plugins/slick.rowselectionmodel';
2222
import { AfterViewInit, Component, EventEmitter , Injectable, Input, Output, OnInit } from '@angular/core';
23+
import { Router, NavigationEnd, NavigationStart } from '@angular/router';
2324
import { castToPromise } from './../services/utilities';
2425
import { GlobalGridOptions } from './../global-grid-options';
2526
import { CellArgs, Column, FormElementType, GridOption } from './../models';
@@ -76,12 +77,20 @@ export class AngularSlickgridComponent implements AfterViewInit, OnInit {
7677
private gridExtraService: GridExtraService,
7778
private filterService: FilterService,
7879
private resizer: ResizerService,
80+
private router: Router,
7981
private sortService: SortService
8082
) {}
8183

8284
ngOnInit(): void {
8385
this.gridHeightString = `${this.gridHeight}px`;
8486
this.gridWidthString = `${this.gridWidth}px`;
87+
88+
// on route change, we should destroy the grid & cleanup some of the objects
89+
this.router.events.subscribe((event: NavigationEnd) => {
90+
this.grid.destroy();
91+
this._dataView = [];
92+
this.filterService.clearFilters();
93+
});
8594
}
8695

8796
ngAfterViewInit() {

0 commit comments

Comments
 (0)