5

My XPage has a view data source with a search formula ("Search in view results") constructed from URL parameters.

The search results are displayed in a repeat control that sits inside a panel. I want to hide this panel if there are no search results and display an appropriate message instead.

The panel is visible based on the following code:

var vec:NotesViewEntryCollection = view1.getAllEntries();
vec.getCount() != 0;

However it seems that getAllEntries returns all entries in the view before the filtering takes place. The Help for AllEntries says "If a view is filtered by FTSearch, this property returns the entries in the filtered view."

Have I misunderstood this? Is there a way that I can get the number of entries AFTER the filtering has taken place?

Florin Pop
  • 5,105
  • 3
  • 25
  • 58
Martin Perrie
  • 398
  • 5
  • 16

2 Answers2

16

When you're accessing the dominoView datasource via SSJS you're not getting the dominoView but the NotesView associated with it. That's why the properties and methods available are for the NotesView class. But the search is being performed on the dominoView datasource front-end not on the NotesView object associated with it.

Instead of using the datasource, get the control that uses it (e.g. A repeat, viewPanel etc) and use the getRowCount() method. This will give you the right total. E.g.

getComponent("repeat1").getRowCount() 
Florin Pop
  • 5,105
  • 3
  • 25
  • 58
Paul Stephen Withers
  • 15,699
  • 1
  • 15
  • 33
  • That sorted it. Thanks, Paul. – Martin Perrie May 25 '12 at 10:43
  • This is something I'd like to do, as well. But it doesn't work if I have a pager attached to my repeat; I just get the count of the number of items on the current page, rather than the count of all filtered view items. Is there any way to do it in this case...? – Reid Rivenburgh Jan 08 '16 at 18:03
  • Just FYI , TeamStudio Unplugged does not have getRowCount() implemented (Unplugged is a mobile app that replicates NSF files a tablet for offline usage. Unplugged has a rendering engine for XPages). – xpagesbeast Mar 14 '18 at 20:06
1

Using the View caption property....

sample: "Displaying 30 of 30220"

<xp:this.caption><![CDATA[#{javascript:return "Displaying " + getComponent("viewPanel1").getRowCount() + " of " + view1.getAllEntries().getCount();}]]></xp:this.caption>

NOTE: This counts the categorized row as well.

xpagesbeast
  • 776
  • 1
  • 10
  • 21