When closing a navdrawer, the Igx Grid does not resize, as it stays the same width as if the navdrawer wasn't closed.
When the navdrawer remains is open, the page with the grid loads in
When the navdrawer is closed, the grid doesn't resize, staying the same width as it did before the navdrawer was closed.
Expect the Igx Grid to resize to the full width of page after a navdrawer is closed.
1) Start at a screen without the IgxGrid, open the navdrawer

2) Navigate to the page with a grid from the navdrawer

3) Close the navdrawer

The problem is in the grid width calculation. I'll take it.
Linking a forum post that it looks like has the same issue: https://www.infragistics.com/community/forums/f/ignite-ui-for-angular/119473/simplest-way-to-style-grid
@mpavlinov
We found a temporary solution. We created an observable on the the navdrawer closing, and had each component with tables subscribe to that observable in the ngOnInit method and reflowing.
Service w/ Observable
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ScreenResizeEventService {
private _resizeEvents = new Subject<string>();
resizeEvents$ = this._resizeEvents.asObservable();
constructor() { }
public next(resizeEvent: string) {
this._resizeEvents.next(resizeEvent);
}
}
Component with Navdrawer
public ngOnInit(): void {
this.navdrawer.closed.subscribe(closed => {
this.sres.next('closed');
});
// Other code
}
Component with Table
ngOnInit(): void {
// Other code
this.sres.resizeEvents$.subscribe(resized => {
this.grid.reflow();
});
}
@joedementri Yes. The current solution is to call manually IgxGridComponent.reflow when the IgxNavigationDrawerComponent opens/closes. The limitation is because the horizontal virtualization relies on pixels and we're recalculating percents to pixels and there is no appropriate event handler that will allow us to do this automatically without compromising the performance.
Hey @joedementri, another approach that you may consider is to use HostListener for document transitionend and reflow the grid there.
@HostListener('document:transitionend')
public transitionEnd() {
this.grid.reflow();
}
Thank you @zdrawku , that solution is better than the one we had previously as this one doesn't cause a ViewDestroyedError to be thrown when the navbar closes
Most helpful comment
The problem is in the grid width calculation. I'll take it.