Reputation: 830
I have a jsp page which contains a list of more than 1000 objects. Due to my requirement I have to show all the 1000 records on the same page without any pagination. I have a javascript method which add the rows into a table on document ready function.
I have 2 problems: 1. Javascript method has the struts tags to fetch labels and list values and then it adds rows into the HTML table. This method takes a lot of time as all the tags are taking lot of time to be resolved from server.
PS: All my 1000 records are from a single table and I can fetch them in no time. Problem is occurring only when rendering for those records happens.
Upvotes: 1
Views: 852
Reputation: 2674
First, only load 50 entiries to the page on the document.ready()
call.
Use the .scroll()
method from jQuery to trigger the event to append 50 more entires once the user hits the end of your table.
$('#table').scroll(function() {
if($('#table').scrollTop() + $('#table').height() == $('table').height()) {
for(var i = 0; i <= 50; i++) {
//Append next value in your array to bottom
}
}
});
Upvotes: 2