This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.



Mar 16, 2011, 5:56 AM
178 Posts

The 'first' parameter (first row index) is missing using a view as a datasource for repeat control

  • Category: Other
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 3
For a View container control you have the 'first' (first row index) parameter. However if you use a view as a datasource for a view this parameter is lacking.
 
I am working on a 'spotlight' function where I would like to display 1 document from a view in random order. Since there is no '&start=' option for the view data source I get sometimes in my repeat control no results returned when using something like:
 
var v:NotesView = database.getView("$v-pixbyid");
var num = v.getAllEntries().getCount().toFixed();
return @Integer(num*@Random())
 
for the first parameter in the repeat control. I guess this is because the number is not in the first set of documents returned...
 
Using the startkey option for the view data source does not work with a # in view for the first column.
 
Anyone know a work around?
Mar 16, 2011, 7:15 AM
261 Posts
Re: The 'first' parameter (first row index) is missing using a view as a datasource for re...
How about not using a viewPanel, but binding a panel to a random document from the view using:
 
var vw:NotesView =  database.getView("yourView");
var nrEntries = vw.getEntryCount();
var randomIndex = @Integer( (nrEntries-1) * @Random() + 1 );

vw.getNthDocument( randomIndex );

Mark
Mar 17, 2011, 7:45 AM
22 Posts
Re: The 'first' parameter (first row index) is missing using a view as a datasource for re...
I read an interesting blog post just recently by Rajeev about attempts to use a dataContext as the data source instead of a dominoView.
 
 
I wonder if his methods would suit your proposed solution? 
 
Perhaps this will help - Hope so! 
Mar 17, 2011, 9:55 AM
178 Posts
The example Mark gave works perfectly!
I found an answer to my question in Mark's reply.

This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.