diprokon / ng-table-virtual-scroll

Virtual Scroll for Angular Material Table
https://diprokon.github.io/ng-table-virtual-scroll
MIT License
133 stars 41 forks source link

Table empty when reloaded throug location.back() if window has been resized #108

Open JoranLive opened 1 year ago

JoranLive commented 1 year ago

Angular 14 / Ionic 6 / ng-table-virtual-scroll 1.3

If we go back to the page which was showing an mat-table with virtual scroll, it can appears empty. It happens if the window has been resized before to going back. On mobile device (ionic), it happens if the view is resized because the keyboard has been shown.

My workarround was to subscribe to location and to trigger resize event after rendering.

haolong7 commented 1 year ago

Thanks for the tip, how to "trigger resize event after rendering."?

JoranLive commented 1 year ago

window.dispatchEvent(new Event('resize'));

EthanTuning commented 2 weeks ago

window.dispatchEvent(new Event('resize'));

This was plaguing me. How the heck did you figure this out?

I was having only one case where <tr *matNoDataRow> kept rendering even though I updated the data source's data. It was only the initial page load (and a couple other conditions were met. If I moved my view port at all the data rows showed instantly... was super odd....

But after updating data I tacked your suggestion at the end and boom all was well.. I have absolutely no clue why this worked.