1
var component = getComponent("dvwContent");
return component.getRowCount() + " documents have been found";

If I'm placing this code into a computed value outside of a filtered dynamic view (referred to by "dvwContent"), it should return me the number of entries found, referring to this question & answer: Count entries in XPages view

If the number of hits exceeds the page display limit, it is giving me the number of filled rows on the page + 2. So if I display 25 lines per page, it tells me that "27 documents have been found" (if I display 50 docs, it tells me 52) - even if there are a lot more pages. It works correctly if there are less hits than the page display limit.

Does anybody have a solution for displaying/counting the correct number of hits?

Community
  • 1
  • 1
DonMaro
  • 82
  • 9
  • keep in mind: RowCount() != hit count. It is the rows shown on screen. The bigger number indicates that there are more hits than rows – stwissel Jan 07 '14 at 10:20

1 Answers1

1

As Stefan mentioned in his comment .getRowCount() refers to the rows visible on the page. From what I get you're interested in the entries of the view rather than the rows shown by the redering component.

One option that comes to my mind would be to access the viewEntryCollection object through the Domino view in question and then get the entry count from that:

var vw=database.getView("dvwContent");
var filter=["someFilter"];
var vec=vw.getAllEntriesByKey(filter, true);
return vec.getCount().toString() + " documents have been found";
Lothar Mueller
  • 2,528
  • 1
  • 16
  • 29
  • Good idea, Lothar, but the getAllEntriesByKey method strictly checks the view's entries based on the columns of the view. But the filter value does not necessarily apply/match to the first (or even any) column of the (backend) view. For example, I'm able to filter by a creator's name which the view has no column for. – DonMaro Jan 08 '14 at 15:44
  • I assume a FT search would give me the same result as the application of the filter to the view, but this would require me to perform the search twice on the same page which I tried to spare (regarding server load and traffic); so I thought I could get the information from the result of the filtering, resp. the hits. – DonMaro Jan 08 '14 at 15:46
  • Ok, I checked the database again, and found that the filtering is switching the evaluated view to exactly one with a matching first column - so if I'm filtering for the creator, the view used in the backend has the creators' names as first column. Your piece of code absolutely works! – DonMaro Jan 08 '14 at 16:06