Welcome to the IBM Collaboration Solutions Community IQJam.
UsernamePassword
Reset Password | Register
   
Home | Leader Board | Tags | Help
Need to count number of documents from a view 
Hi Friends,

I am facing a strange problem while using one of the server side javascript to to get number of total document from a view.

I an using below code:
getComponent("MyViewName").getRowCount();

If my number of document is more than 121 then it display only 121 by default and when i click to 2nd page it gets increased by 30, which would be 151, Again when I click to 3rd page its again increased by 30, that will be 181. Where I have fixed my pagination with 30 record with each page. 
But when it reaches to total number of document s then its value never gets changes. And again if I reach to 1st page it shows me 121 records.

Friends, Please tell or suggest me why this is happening. Is there some settings or what I am doing wrong.

I will be very thankful to you for your kind response.

With regards,
Vikas K Sinha
Domino Development / XPages
Vikas Sinha - about 1 year ago |  |  | Viewed 317 times

There are 2 answers

1votes
Marked as correct on11/6/10 2:08 AM
The rowCount property of the view control is not where you want get this data ... the rowCount is actually looking at "cached data" within the control itself, not the entire view (note that this is what you want, you don't want the control to cache the entire view and provide a row count for that). Think of the view control as not the "view" itself, just a control to handle looping and rendering through the data on the XPage.  To get the rowcount for a view, look at using @Elements(@DbColumn()) (if your view is small enough) or use SSJS to get the view (ie database.getView("viewName") ) and calculate the number of view lines from there. (like you would have done in lotusscript)


Jeremy Hodge - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community


0votes
Thanks Jeremy for your response. I am agree with your solution using @Elements but my views contains almost 4000 documents and even it grown up in future. Now second approach like using database.getView("ViewName"), Can you please elaborate me more on this what method and function or property I need to use after creating of view object using SSJS. I will be very thankful for your kind response.
 
Waiting for your response 
 
Regards, 
Vikas K Sinha 


Vikas Sinha - about 1 year ago | 
Voting
Vote on the answer to show whether you think the answer is correct or useful to the rest of the community.

Answers with more votes are more visible to the rest of the community