This is a migrated thread and some comments may be shown as answers.

DropDownList infinite scroll based on virtualization

1 Answer 1526 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Салашний
Top achievements
Rank 1
Салашний asked on 26 Jun 2019, 01:47 PM

I have been trying to implement infinite scroll on DropDownList component, using virtualization, because it's the only way to track scrolling. When I reach the end, of the DropDownList's items, I make a request to the server, and load new chunk of data, and add this new data to existed. In my case, the property virtual.total is based on the items length. But when I get new items, the length of the items increases, and accordingly virtual.total changes, that leads to resetting position of the scroll bar to the top of the popup. 
I have already found the place in the source code, where is it going, and I have found the only one way to fix this problem so far. It's changing   componentDidUpdate  method of the DropDownList.prototype directly, but it is very bad practice..
Are there ways to implement these changes in other way?

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 27 Jun 2019, 12:48 PM
Hello, Салашний,

Thank you for the details.

If the desired result is to achieve a infinite scrolling, I can suggest the following:

1) Wrap the DropDown inside a div and add an onScroll event handler to it.

2) Inside the event check if the scroll is at the bottom and append the new data. This will not reset the scroll position.

Please take a look at the example showcasing this:

https://stackblitz.com/edit/react-e6ugkn?file=app/main.jsx

I hope this approach will help the achieve the desired result.

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Салашний
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or