After reading this tip, if you decide that it would be good to add to your archive or that you think a friend would like it, go to the bottom of the tip and click "Have Tip Mailed".
If you have ever wanted greater control over the way your views display on the Web you may have considered using a view that displays HTML. That's great! But now you realize you don't have alternating row colors. Attached is a column formula using JavaScript to get those alternating colors.
The formula is a combination of @Formula, Javascript, and HTML. You can use @Formulas for data manipulation then use JavaScript to get the modulus of the @DocNumber. If @DocNumber returns an odd number then the variable "color" gets light gray otherwise it gets dark gray. That javascript variable is then incorporated into a document.write that writes each line of the view as the page loads. (Mind the quotes!)
You can achieve the same results in a dblookup but you'll have to write into the JavaScript
another variable that is incremented for each row because you won't have access to the
@DocNumber
Create a single view column using the following code. Once added, go to the property box for the
view and select the beanie tab. Select "Treat view contents as HTML". You will notice in the
formula that we have used the name of the color interchangably with the HTML hex code for the
color. Replace the FormVariableOne with your variable. You may also want to change the
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.
com:= @ReplaceSubstring(@Trim(FormValiableOne);@NewLine;"n");
"<script> var color=(("+@DocNumber("")+"%2)==1)?
"Yellow":"#FFFFFF";"+
@Char(13)+
"document.write("<td width=450 bgcolor="+color+">"
+@Name([CN];Author) + " entered on: "+@Text(@If
(CreateDate="";@Created;CreateDate)) + "</td></tr><tr><td
bgcolor="+color+">" +@If(Title="";" ";"Comment: " +com) +
"</td></tr>");</script>"+@Char(13)
When you have completed the view, create a new form. Name the form "$$ViewTemplate for XYZ". Replace the XYZ with the actual name you gave the view. Add a field to the form called "$$ViewBody" and add the following code around it.
[add pic1] Sample of what this technique would look like if used for a view on DominoTips.
[add pic]
This was first published in November 2000