Code Snippets for Next & Previous Navigation Buttons in View Template Form

Mindwatering Incorporated

Author: Tripp W Black

Created: 08/26/1999 at 07:51 PM

 

Category:
Notes Developer Tips
Formulas, Views, ViewTemplates

(Updated 2002 & 2003)

Field Setup for Use of Next & Previous Navigation Buttons in View Template ($$ViewTemplate) Form

Query_String_Decoded - CFD - Text
Query_String_Decoded

viewAlias - CFD - Text
tmp:=@Subset(@ViewTitle;-1);
@ReplaceSubstring(@ReplaceSubstring(tmp; "\\"; "/"); " "; "+")

Start - CFD - Text
tmp:=@LowerCase(Query_String_Decoded);
tmp2:=@Right(tmp; "&start=");
tmp3:=@If(@Contains(tmp2; "&"); @Left(tmp2; "&"); tmp2);
@If(tmp3=""; "1"; tmp3)

Count - CFD - Text
tmp:=@LowerCase(Query_String_Decoded);
tmp2:=@Right(tmp; "&count=");
tmp3:=@If(@Contains(tmp2; "&"); @Left(tmp2; "&"); tmp2);
@If(tmp3=""; "10"; tmp3)

NAVIGATION BUTTONS:
Previous Button
Link Hotspot --> URL -- Formula
tmp:=(@TextToNumber(start) - @TextToNumber(count));
tmp2:=@If(tmp<1; "1"; @Text(tmp));
"/" + dbPath + "/" + @Subset(viewAlias; -1) + "/?OpenView&start=" + tmp2 + "&count=" + count
Hide-when:
tmp:=@TextToNumber(start);
tmp<2

Next Button
Link Hotspot --> URL --> Formula
tmp:=(@TextToNumber(start) + @TextToNumber(count));
tmp2:=@If(tmp<1; "1"; @Text(tmp));
"/" + dbPath + "/" + @Subset(viewAlias; -1) + "/?OpenView&start=" + tmp2 + "&count=" + count
Note: determining the end of a view is a tricky thing. Categorized view navigation is tricky due to twistie collapsing and expansion. If it is a non-categorized view you can do a count on view.entries() using queryopen or dbcolumn count if you know the view is small.


Hiding View Previous & Next Buttons When No Previous or Next Page

Hiding the Next and Previous buttons in a view template when they are not appropriate.

You have created a view template with a bunch of hotspots at the top and bottom of the form
(Next, Previous, Home, Search, etc). The Next and Previous buttons use the formulas:


@DbCommand(“Domino”; “ViewNextPage”) and
@DbCommand(“Domino”; “ViewPreviousPage”)


respectively. They work OK except for the fact that the buttons are displayed even when there
isn’t a next or a previous page of the view. You want to hide the Previous button when at the top
of the view, and the Next button when at the bottom of the view.

(The easiest way to hide the previous is not to do so. Always make previous the javascript history.go(-1) command.)

This solution only works for an unexpanded view. A complete solution will be published shortly.
I hope the partial solution shown here will point you in the right direction at least.


1. Put your hotspots in a table without borders. For example, if you have 4 hotspots, create a 1 row, 4 column table.

2. Add the following hidden fields to the form:

Query_String (Text, Computed for display - formula is Query_String)

ViewLines (Number, Computed for display - formula below: )
tViewContents := @DbColumn(“Notes”:”NoCache”; “”; @ViewTitle; 1);
@Elements(tViewContents)


This field counts the number of ‘lines’ in the view, either categories or documents.
(However, category expansion makes the view always changing therefore making the number a shooting target.)

CurrentLine (Number, Computed for display - formula below: )
tNode := @RightBack(Query_String; “&Start=”);
@If(tNode = “”; 1; @TextToNumber(tNode))
MaxLines (Number, Computed for display)


This field should contain the maximum number of lines
that Domino displays in a view. The default is 30 but
this default can be changed in the server’s server
document in the public Address book. You could hard
code the value if you think it is unlikely to change on
any server within your company. Alternatively, you could
provide a formula to look up the address book and obtain the value.

3. Go to the table cell containing the Next hotspot and enter the following
hide-if-formula-is-true formula: (CurrentLine + MaxLines) > ViewLines

4.Go to the table cell containing the Previous hotspot and enter the following
hide-if-formula-is-true formula:


CurrentLine = 1


previous page