How to load data when scroll the bar

We have more than 4000 pieces of data.
We want to load the data in pages by listening to the scroll bar,so,how to do with Dhtmlx-gantt? thx

Hello,
One of the options is to use onGanttScroll handler to load the tasks when you scroll to the last rendered task:
https://docs.dhtmlx.com/gantt/api__gantt_onganttscroll_event.html ;
You can get the number of tasks visible on the screen (those that are not collapsed) by getVisibleTaskCount method:
https://docs.dhtmlx.com/gantt/api__gantt_getvisibletaskcount.html ;
and when the scroll reaches the last task, you can parse/load the data.
To prevent scrolling Gantt to the top when you parse/load the data, you can memorize the scroll position by getScrollState method:
https://docs.dhtmlx.com/gantt/api__gantt_getscrollstate.html ;
and return it after parse/load with scrollTo method: https://docs.dhtmlx.com/gantt/api__gantt_scrollto.html ;
Please check the example of how it might be implemented:
https://snippet.dhtmlx.com/zrm1h2wr

1 Like