当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Infinite scroll with dynamic data sorted on last modified status

问题描述:

Hi i was able to implement infinite scroll when the data is static. But when the data is dynamic in nature, let us say i have a table TABLE with fields Name, Last_modified. My requirement is to load the results batch by batch sorted on the decreasing order of Last_modified column in a web page. Let us say my page-size is 10, if i load the recently modified 10 items in the web page and if the user scrolls down to the bottom of the web page then i am supposed to load the next recent 10 items.

If the data is static, then it is easy to implement but as my table data is dynamic in nature i.e Last_modified column can change dynamically so there is a possibility that a row which is already served to the user may be a recently updated row or a row which was not updated previously may be modified/updated by the time when we do the subsequent request.

I thought, i can solve the problem by intimating the server about the already served rows so that the server can filter the already served rows and give the recently updated rows for the rest of the data.

But this is not scalable as the number of already served rows to the users eventually pile up and i will have to send this huge amount of already served row id's to the server which hits the network!

Is there any cleaner way of solving this issue?

网友答案:

Maybe can you serve rows with data + id (directly mysql's ones).

So your client's request can send the last served item ID, you can now know which data to send back to the cliend (id + 1, +2...).

Show some code for more precise answer :)

分享给朋友:
您可能感兴趣的文章:
随机阅读: