Home > Domino Tips > Developer > Formula > A simpler pagination view for Lotus Notes documents on the Web
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

FORMULA

A simpler pagination view for Lotus Notes documents on the Web


Hemang Kapadia
04.24.2007
Rating: -2.67- (out of 5)


Lotus Notes, Domino, Workplace and WebSphere tips and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Do you get frustrated by having to click through endless "Previous" or "Next" buttons to find a buried Lotus Notes document that is, for example, on the tenth page.

Since a Web browser may take a long time, Notes/Domino developers like to keep to a minimum of 50 documents per page and provide the normal Previous/Next buttons, using the Lotus Domino @DbCommand("Domino"; "ViewPreviousPage") and @DbCommand("Domino"; "ViewNextPage").

Below you'll find code and instructions that will allow you to insert a computed value in your $$ViewtemplateDefault template. Once implemented, your Lotus Notes users will find it much easier to navigate through multiple pages on the Web.

Along with this, you will have the Previous/Next button, First/Last, GoTo page, and Documents per page features.

---------------------------------------------------------------------------------------------------------------

Step 1: Create three "computed for display" fields on your $$ViewtemplateDefault template, and label them as follows:

ViewName  :@Subset(@ViewTitle;-1)
ParamCount :@UrlQueryString("count")
ParamStart :@UrlQueryString("start")

---------------------------------------------------------------------------------------------------------------

Step 2: Copy the following code into the form:

<table border=0 width=50% align=center>
<tr><td colspan=2 align=center class=
viewheader><b>
Configuration</b></td></tr>
<tr>
<td><b>Documents 
Per Page :</b></td>
<td>
<select name='Pages' 
onChange='DocsPerPage()'> <option>
--Select--</option> <
option value='5'>5</option> 
<option value='10'>10</option> 
<option value='15'>15
</option> <option value='20'>
20</option> 
<option value='25'>25</option> 
<option value='30'>30</option> 
<option value='35'>35</option> <
/select><span>Goto page :
<select name='GotoPage' 
onChange='GotoPg(this)'> 
<<<<<<<COMPUTED 
VALUE 1 >>>>>>>> 
</select> </span></td> </tr>
</td> </table>

<<<COMPUTED VALUE 1>>>>: contains:


Total:=@Count(@DbColumn
("";"";@Subset(@ViewTitle;-1);1));
Viewname:=@Subset(@ViewTitle;-1);
cnt:=@ToNumber(@UrlQueryString("count"));
@If(cnt=0;@Return("");"");
Start:=@ToNumber(@UrlQueryString("start"));
Limit:=@Text(Total/cnt);

LastPagelimit:=@If(@Contains(Limit;".");
@Integer(@ToNumber(Limit))+1;
@Integer(@ToNumber(Limit)));
HTML:="<option value=''>
--Select--</option>"; 
@For(i:=1;i<=LastPagelimit;i:=i+1;
HTML:=HTML+"<option value='"+
@Text(i)+"'>"+@Text(i)+"</option>") ; HTML

---------------------------------------------------------------------------------------------------------------

Step 3: Add this pagination bar:

<div id='pagination' align='center'>
<<<< COMPUTED VALUE 2>>>>
</div>


<<<< COMPUTED VALUE 2>>>> 

should contain this:


Total:=@Count(@DbColumn
("";"";@Subset(@ViewTitle;-1);1));
Viewname:=@Subset(@ViewTitle;-1);
cnt:=@ToNumber(@UrlQueryString("count"));
@If(cnt=0;@Return("");"");
Start:=@ToNumber(@UrlQueryString("start"));
Limit:=@Text(Total/cnt);

LastPagelimit:=@If(@Contains(Limit;".");
@Integer(@ToNumber(Limit))+1;@Integer
(@ToNumber(Limit)));
Maxlimit:=@If(@Contains(Limit;".");@Integer
(@ToNumber(Limit))+1;
@Integer(@ToNumber(Limit)));
MaxLimit:=@ToNumber(@If(@ToNumber
(maxLimit) >10;10;Maxlimit));

pageNumber:= @Integer(((Start-1)/cnt) / Maxlimit);

FirstPage:=@Repeat(" ";0)
+"<a href='./"+Viewname+
"?openview&start=1&count="+@Text(cnt)+"
'>First </a>  "; 
LastPage:="<a href='./"+
Viewname+"?openview&start="
+@Text(((LastPagelimit-1)*cnt)+1)
+"&count="+@Text(cnt)+"
'>  Last </a>";

Fromcnt:=pageNumber*Maxlimit+1;
ToCnt:=Fromcnt+Maxlimit-1;

ToCnt:=@If( (Fromcnt+Maxlimit-1)*cnt >= 
Total;LastpageLimit;Fromcnt+Maxlimit-1);

@For(i:=Fromcnt;i<=Tocnt; i:=i+1;
@Do(
Newstart:=@Text(((i-1)*cnt)+1);
FrontAHref:="<a href='./"+Viewname+"
?openview&start="+Newstart+"&count="+
@Text(cnt)+"'>";
RearAHref:="</a> ";
@If((start-1)/cnt =i-1 ;
 h:=h+"<font color='red'><b>"+@Text(i) 
+" <b></font>";  
h:=h+FrontAHref +@Text(i) + RearAHref)
)
);

NextDisplay:=@If(start+cnt >
@ToNumber(lastpagelimit)*cnt;"none";"");
NextPage:="<a  style='display:"+ nextDisplay +" 
' href='./"+Viewname +"?openview&start=" +
@Text( ((start)+cnt)) +
"&count="+@Text(cnt)+"'><img 

src='rightArrow.jpg' align='bottom' 
style='border:0px' alt='Next'></img></a>";

PrevDisplay:=@If(start<=1;"none";"");
PrevPage:="<a style='display:"+ PrevDisplay +" 
' href='./"+Viewname +"?openview&start=" + 
@Text( ((start)-cnt))
+"&count="+@Text(cnt)+"'>
<img src='leftArrow.jpg' align='bottom' 
+style='border:0px' alt=
'Previous'></img></a>";

FirstPage +PrevPage +"  " +
h + +"  " + NextPage + LastPage

---------------------------------------------------------------------------------------------------------------

Step 4: Add this computed value below the table displaying documents (showing 51-100 Records of 361 ):

<div align='center' id='ShowRecs' 
style="display:none1"
><br> <<<<<COMPUTED 
VALUE 3 >>>>> </div>

<<<<<COMPUTED VALUE 3 
>>>>> should contain this:

Total:=@Count(@DbColumn
("";"";@Subset(@ViewTitle;-1);1));
Start:=@UrlQueryString("start");
cnt:=@UrlQueryString("count");
cnt:=@ToNumber(cnt)+@ToNumber(Start)-1;
cnt:=@Text(@If(cnt>Total;Total;cnt));

var1:="Showing " + start +" - " + 
cnt   +" of " + @Text(Total) + " Records.";
var2:="Showing " + start +" of " +
 @Text(Total) + " Records.";
@If(cnt=start;var2;var1)

---------------------------------------------------------------------------------------------------------------

Step 5: Add these JavaScript functions in the JavaScript header; they are used in the combobox onChange event:

function DocsPerPage()
{

location.href='./'+document.forms[0].
ViewName.value+'?openview&start=1&count='
+document.forms[0].Pages.value
}

function GotoPg(obj)
{

PageNumber=obj.options[
obj.selectedIndex].value-1
start=PageNumber * 
document.forms[0].ParamCount.value+1
url='./' +document.forms[0].ViewName.value
+'?openview&start='+start + '&count=' 
+document.forms[0].ParamCount.value
location.href=url
}

---------------------------------------------------------------------------------------------------------------

Step 6: This is the most important step, as it will go into an infinite loop for the computation and you'll get a "memory out of space" error.

Add this "Onload" event of the form:

if(location.href.indexOf("count")<0)
location.href='./'+document.forms[0]
.ViewName.value+'?openview&start=1&count=5'

---------------------------------------------------------------------------------------------------------------

Note: Your view must be opened using the URL parameters: start=1 and count=X. For example:http://server:port/Demo.nsf/All?openview&start=1&count=5

You can also place the <<<<<computed value 2 >>> above and below the table containing the documents.

Do you have comments on this tip? Let us know.

Related information from SearchDomino.com:

  • Tip: Improve the performance of Domino Web forms
  • Tip: How to create non-scrolling Lotus Domino view headers on the Web
  • FAQ: Formula language for Lotus Notes and Domino
  • Tutorial: An introduction to Formula language for Lotus Notes
  • Reference Center: Web development tips and resources

    This tip was submitted to the SearchDomino.com tip library by member Hemang Kapadia. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

    Rate this Tip
    To rate tips, you must be a member of SearchDomino.com.
    Register now to start rating these tips. Log in if you are already a member.




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


    RELATED CONTENT
    Web Development for Lotus Notes Domino
    Top 10 issues when developing Lotus Notes Domino Internet applications
    Top 10 Lotus Notes Domino programming and development tips of 2007
    Programmatically copy and hide attachments in Lotus Notes rich-text fields
    Programmatically edit a rich-text field table from within the Lotus Notes client
    Troubleshooting Lotus Notes Domino tabbed table problems
    How to validate Lotus Notes forms on a Domino server without losing entered data
    A bevy of Notes/Domino development tips
    Sizer
    Top 10 Notes/Domino developer tips of 2006
    A smorgasbord of Notes/Domino development tips

    Lotus Notes Domino Formula Language
    Stop response documents from showing in a Lotus Notes form
    Formula language button manages Deny Access list searches
    Add a program doc to compact Lotus Notes databases automatically
    Top 10 Lotus Notes Domino programming and development tips of 2007
    Retrieve Lotus Notes names from a nested group using @DBLookup
    Top 5 @DBLookup tips
    Create a computed Lotus Notes field to list Personal Address Book names
    Show multiple Lotus Notes document fields in a single view column
    Lotus Formula language coding primer
    How to send a document as a link in a Lotus Notes email

    Formula
    Formula language button manages Deny Access list searches
    Retrieve Lotus Notes names from a nested group using @DBLookup
    Create a computed Lotus Notes field to list Personal Address Book names
    Show multiple Lotus Notes document fields in a single view column
    How to send a document as a link in a Lotus Notes email
    How to generate formatted sequence numbers with Formula language
    A bevy of Notes/Domino development tips
    Easily implement attachment fields in a Web form using Formula
    Programmatically create a shortcut for Lotus Notes
    Universal @Formula for converting list synonyms

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

  • HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




    All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts