Alternating Row Colors For Web View

Alternating Row Colors For Web View

The following LotusScript agent creates a view for browser users using
alternating row colors, a function not provided by the Domino model. This
particular example only loops through one view and prints a two column table
with the field values. This agent is very scalable and can be easily modified
to add some additional options like hypertext links using the doc.UniversalID
method. The key is the Print commands and the combination of HTML and
LotusScript variables. The code resides in an agent that is set to "Run Once".
Sub Initialize
Dim session As New NotesSession, db As NotesDatabase, view As NotesView
Dim doc As NotesDocument, doc2 As NotesDocument, bgcolor As String
Set db = session.CurrentDatabase
Set view=db.GetView("Time per Step")
Set doc = session.DocumentContext
'****** the following line starts the HTML and sets text color and document
background color
Print {&LThtml>&LTbody text="black" bgcolor="white">}
'****** additional HTML could be added here for a header
'****** the next line creates the table for the data and sets the column labels
'****** to add additional column labels add another &LTTH></TH> with the label in
between
Print {&LTCenter>&LTTable width=100%>&LTTR>&LTTH>Column 1 Title</TH>&LTTH>Column 2
Title</TH>}
Set

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

doc2 = view.GetFirstDocument
Do While Not (doc2 Is Nothing)
'****** the next line sets the font and the if then else that follows is what
controls the
'****** alternating row colors
fontface = "Helvetica"
If bgcolor = "Silver" Then
bgcolor="White"
Elseif bgcolor="White" Then
bgcolor="Silver"
Else
bgcolor="Silver"
End If
'****** note: all data between &LTTR></TR> is row data
'****** note: all data between &LTTD></TD> is cell data
'****** note: add another &LTTD></TD> within the &LTTR></TR> to create another
column
'****** the following four lines write one row of data with two columns
Print "&LTTR VALIGN=BASELINE BGCOLOR=" & bgcolor & ">&LTTD>"
Print "&LTFont Size=-1 Face=" & fontface & ">&LTB>" & doc2.Requestor(0) &
"</B></TD>"
Print "&LTTD Align=center>"
Print "&LTFont Size=-1 Face=" & fontface & ">&LTB>" & doc2.OrderType(0)
& "</B></TD></TR>"
Set doc2 = view.GetNextDocument(doc2)
Loop
Print {</Center></Table>}
End Sub

This was first published in November 2000

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.