Data View with a NotesViewEntryCollection
Jan 20, 2015

So I've been wanting to use a Date View for a while, but I've not had the time I need to sit down and puzzle it out. And (soap box here) the examples given are pretty complex. I do have a sample based on Brad's work that I will be posting. But as I get that together, here is a tidbit.
When you use a Data View, you are only given the option of selecting a Domino View. I wanted to see if you could do it with a collection. It turns out you can. What I did was this (in my odd discovery process) I created a DataTable based on a NotesViewEntryCollection of all entries in a view. I copied the <xp:this.value>  node from it and replaced the <><xp:dominoView ...> nodes in the dataView. And the page renders. I've only put a pager in to see if it's got full functionality, and that's working, so I suspect that various other things will as well.
Here is the entire XPage. It should work for you just changing the view name and the field you get. Plus, it's a start to using the Data View if you've not started yet :)

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="" xmlns:xe="">

        layout="Previous Group Next"
javascript:var nView:NotesView=database.getView('Name');
var nVEC:NotesViewEntryCollection=nView.getAllEntries();
return nVEC;}]]></xp:this.value>
            <xe:viewSummaryColumn value="#{



Add a Comment 
More Actions 
Comments (4)

1 Brad R Balassaitis commented Jan 21 Permalink Recommendations 0
Great tip! I've used this with arrays of JavaScript objects as well (as a way to minimize overhead when refreshing). The Data View is an incredibly flexible control.

2 Brian M Moore commented Jan 21 Permalink Recommendations 0
@Brad - Thanks Dude! I'm a fan of yours - and so it's an honour to see you commenting here.


Can/will you post an example of using JS Objects? Like so much of what you do, I'd like to adopt it.

3 Brad R Balassaitis commented Feb 1 Permalink Recommendations 0
Below is a working example (it looks like it's stripping out the reference to the SSJS script library, but I think everything else is in tact).


Basically, I set up a script library function to walk a view and build an array of objects with data to display. The data view page includes the script library and gets the data by setting the "var" property to: return getData(); (there's no "data" property to set, because it's not using a view data source). Each data object has a Name, City, and Country property. I set the Name as the summary column and the other two as extra columns.
I've used this in combination with a scope variable to check whether I should re-build the data or just leave it as is, so it's not refreshing as much. I don't have benchmarks on it, but it makes sense to me conceptually.
[Data View XPage]
<xp:view xmlns:xp="" xmlns:xe="">
<xe:dataView id="dataView1" var="dvRow" value="#{javascript:return getData();}">
<xe:viewSummaryColumn value="#{
javascript:return dvRow.Name;}"> 

<xe:viewExtraColumn value="#{
javascript:return dvRow.City;}" columnTitle="City"> 
<xe:viewExtraColumn columnTitle="Country" value="#{
javascript:return dvRow.Country;}"> 

[Script Library Function]
function getData() {
var data = [];
var vw:NotesView = database.getView('ByName-First'); 
var nav:NotesViewNavigator = vw.createViewNav(); 
var ve:NotesViewEntry = nav.getFirst(); 
while (ve != null) { 
var columnValues = ve.getColumnValues();

var thisRow = {}; 
thisRow.Name = columnValues.elementAt(0) + ' ' + columnValues.elementAt(1); 
thisRow.City = columnValues.elementAt(3); 
thisRow.Country = columnValues.elementAt(6); 

var tmpentry = nav.getNext(); 
ve = tmpentry; 

return data; 

4 Brian A Moore commented Feb 1 Permalink Recommendations 0
That's amazing! Thanks!
This is an archive of my previous blog attachments are in the download control