Home > Domino Tips > Developer > Domino > Alternate row colors/column colors for any sort of Web view (categorized & uncategorized)
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DOMINO

Alternate row colors/column colors for any sort of Web view (categorized & uncategorized)


Dhana Sekar
04.02.2002
Rating: -4.27- (out of 5) Hall of fame tip of the month winner


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


There has been quite a few solutions to produce alternate row colors for a Web view. They all involve writing cluttered HTML in the column headings, treating view contents as HTML, or using agents, etc. But the following solution is purely a javascript function and has nothing to do with Domino view design. Part of this idea was derived from a posting in the notes.net site.

Code

Step 1.) Create a view with few columns(Let it be uncategorized initially).

Step 2.) Embed the view in a form(Display as HTML).

Step 3.) Put the following code in the Onload event of the form.(Or have it as a function in the JS Header and call it in the OnLoad event).

var tableElements = document.body.all.tags("table");
var table = tableElements[tableElements.length-1];
var headlength=rowlength="";
heads = table.getElementsByTagName("th") ;
headlength=heads.length;
	
// If the view is categorized , use this line, else comment it
//headlength=headlength-1;
		
for( i = 0; i <headlength; i++)
  heads[i].bgColor = '#D2D2D2';
       
rows = table.getElementsByTagName("tr") ;
for( i = 0; i < rows.length; i++)
{
if(i % 2)
{
// If the view is not categorized , use this line		
celllength=rows[i].cells.length;	
// If the view is categorized , use this line			
//celllength=rows[i].cells.length-1;
		 	
for (var c = 0; c < celllength; c++)
  rows[i].cells[c].bgColor = '#F4F4F4';
}       
else
rows[i].bgColor='';
}

(The code is self explanatory. It gets the table element, changes the background color of the cells. The above code works fine for an uncategorized view.)

Step 4: For a categorized (single or many), uncomment the following lines,

//headlength=headlength-1;
//celllength=rows[i].cells.length-1;

and comment the following line.
//celllength=rows[i].cells.length;

This should work well for a categorized view.

Step 5 : To provide alternate column color effect, modify the for loop given below,

for (var c = 0; c < celllength; c++)
  rows[i].cells[c].bgColor = '#F4F4F4';

to,

for (var c = 0; c < celllength; c++)
if (c % 2)
  rows[i].cells[c].bgColor = '#F4F4F4';

The above javascript function is fully customizable like,
table.cellspacing='2'
table.cellpadding='2'
and the bgcolor values etc.

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.


Submit a Tip




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


RELATED CONTENT
Domino
Mimic Lotus Notes Domino application functionality on the Web
A single form to view and edit any Lotus Notes document
DECS and DCR external data access considerations
How to create non-scrolling Lotus Domino view headers on the Web
Disabling the 'Submit' button on a form
An easier way to update a rich text field
Results from Default Notes Search have # of responses in brackets
Lotus Notes/Domino veteran offers comprehensive list of app dev tools
Notes to XML. . .and back again
Creating thumbnail images using LS2J in LotusScript

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.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge 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