Incorrect rowHeight calculation when using virtual scrolling #3301
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
I'm submitting a ... (check one with "x")
Current behavior
If a lazy loaded virtually scrolled datatable gets initialized with an empty data in the beginning then the ScrollableView.rowHeight gets calculated from the 'No records found' default row and never gets updated again which leads to incorrect calculation of the lazy requested pages afterwards (in my case the rows are 43px and the 'No records found' row is 22px which logically leads to ca. double page offset size when scrolling).
Looking at the code; the ScrollableView.rowHeight is set in ScrollableView.ngAfterViewChecked. Currently it just gets 'tr.ui-widget-content' element - which is usually the default empty row - and takes the height, which only works if there is already some data there before the view gets rendered (in fact that is how I hackfixed my cases for now i.e. setting a bogus row which is ugly because it is visible before a real lazy load happens).
Suggestion: maybe check the rowHeight every time and take it's max and reset scrolling on change accordingly?
Expected behavior
When scrolling directly to the bottom in the virtually lazy dataTable the last page should be loaded correctly (currently jumps back to beginning due to too big of a page offset).
Minimal reproduction of the problem with instructions
Use dataTable with lazy loading and virtual scrolling, make sure it was rendered once with no data, then set big data and scroll to bottom.
What is the motivation / use case for changing the behavior?
Virtual scrolling in lazy loaded data is very useful.
Please tell us about your environment:
Windows 10, npm, ng console.
Angular version: 4.2.5
PrimeNG version: 4.1.0-rc.3
Browser: Chrome
Language: TypeScript 2.3
Node (for AoT issues):
node --version
= v6.10.3The text was updated successfully, but these errors were encountered: