DataTables sends too many requests when using Scroller
DataTables sends too many requests when using Scroller
Hello,
I am using DataTables with Scoller and for the most part it works great. I have one system where there is a lot of calculations being made and the loading takes about 20 seconds to get a result. (I am working on adding caching to speed this up but it's mostly real-time data).
The issue I am experiencing is: When The data first loads, I get 300 records and scroll down. The initial load works great and it only makes the next request when I get towards 150 records (Although I'd like it to be more around 250 but that's not the problem). After the next request is made, it returns 300 records but only 100 seems to be the actual appended rows (100 for scrolling up and 100 for current view I assume). The issue is, when this request is pending a response and you scroll a little more, it makes a second response and if you move again a third... Now with each request taking about 20 seconds this tends to stack and it has taken up to 15mins to get data back (as the last request is the only one to make any changes to the table). Now I assume this is logical as you would expect to load the proper results when you are scrolling down the page even if no data is shown, this allows you to "jump" to a record.
My question is: How can I make it so that the request is only sent when they reach the end of the list? Also, can I prevent the requests from stacking or is this a proper design. I am going to a lock file check to kill the previous queries as I believe this will prevent the 15 min delay when all the requests are stacked. The end-user seems to scroll multiple times even when the page is pending the request, causing the request stacking. The data is pulled from old legacy system so that is why there is a 20 second process for the data (a lot of calculations between multiple datasets)
My Debug: http://debug.datatables.net/awijug
Thanks for any insight/possible solutions. :)