File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes display few records before JSP loads the rest Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "display few records before JSP loads the rest" Watch "display few records before JSP loads the rest" New topic
Author

display few records before JSP loads the rest

gar tek
Greenhorn

Joined: Mar 07, 2007
Posts: 10
Hi Team,

I am trying to display about 3000 records from a JSON object using jquery datatable..

I want to display about 10 records and then let javascript process the rest of rows.. this way user will be able to see some data.

I tried to do the below in java script..

code to print 10 records
alert("hello");
code to print rest of records

It works fine. Now I remove the alert statement.. then all records are displayed together.

Is there anyway we can display a few records and then display the rest?


tmpArray = [];
for ( i = renderCnt; i < len; i +=1 ) {
thisOne = emails[i];
tmpArray.push( [
thisOne.date,
thisOne.email,
thisOne.type,
thisOne.amt,
thisOne.cost,
'n/a'
] );

}
PUsage.config.dt.fnAddData(tmpArray);


Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

A much better approach, which is covered by a JSP FAQ, would be to do your "paging" at the database rather than at the browser. Why waste resources to fetch and transfer 3000 records when you only need 10?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
gar tek
Greenhorn

Joined: Mar 07, 2007
Posts: 10
It is a requirement from business and they need to see 3000 records in 1 shot no matter. So I need to show 3000 and they also requested that we show about 30 records initially along with a progress bar so user knows something is going on.. Any ideas how to make javascript print a part of it and then continue processing the rest?

It works when I show a alert statement.. but stops working when i remove the alert.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48842

alerts should be avoided because they cause unnatural pausing of script.

First, I'd push back on the rather silly requirement. No one is going to find 3000 records at a time useful. Failing to stem the stupidity, I'd employ Ajax to fetch the data in chunks at intervals.
 
 
subject: display few records before JSP loads the rest