primeng icon indicating copy to clipboard operation
primeng copied to clipboard

DataScroller onLazyLoad callback invoked IFF totalRecords > value.length

Open cuneytcalishkan opened this issue 8 years ago • 2 comments

I'm submitting a ... (check one with "x")

[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior

Current guide/documentation for infinite DataScroller component https://www.primefaces.org/primeng/#/datascroller/infinite doesn't really work. It only shows a first batch of data and the lazy load callback is not called to load the next batch of data. This is because the totalRecords property by default is bound to the length of the value array and the following statement in the code confirms that it won't be calling the lazy load callback: DataScroller.prototype.shouldLoad = function () { if (this.lazy) return (this.rows * this.page < this.totalRecords); else return this.value && this.value.length && (this.rows * this.page < this.value.length); };

Expected behavior

Documentation to be updated accordingly or the behavior to be changed so that the onLazyLoad callback function is invoked regardless of the totalRecords value.

Minimal reproduction of the problem with instructions Follow the documentation on https://www.primefaces.org/primeng/#/datascroller/infinite

What is the motivation / use case for changing the behavior?

Infinite scrolling is useful in case some data is continually fetched in batches from a backend API via a service call or similar behavior and there is no way to know in advance the total amount of data to be transferred unless it is stated in one of the backend responses that there is no more data to load.

I managed to find a workaround to this by updating the totalRecords value to value.length + 1 so that the above mentioned code returns true as a result of shouldLoad() method call. Maybe it would be nice to mention such a trick in the documentation.

Angular version: 6.0.3 PrimeNG version: 6.0.0-rc.1

cuneytcalishkan avatar Jun 14 '18 13:06 cuneytcalishkan

DataScroller is deprecated in favor of VirtualScroller.

cagataycivici avatar Jan 17 '19 09:01 cagataycivici

Hello @cagataycivici, VirtualScroller indeed seems like the future but it lacks a very important feature that DataScroller provides. Removing/updating elements on a DataScroller component results in automatically updating the DOM. However, removing elements in VirtualScroller has no effect on the DOM structure. How can we achieve this? Cheers, Cuneyt

cuneytcalishkan avatar Jan 24 '19 16:01 cuneytcalishkan