Home > Domino Tips > Developer > JavaScript > Alternate row coloring of tables -the next level
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

JAVASCRIPT

Alternate row coloring of tables -the next level


Prashul Kumar
02.05.2003
Rating: -4.00- (out of 5)


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


Domino throws views in tables. Ravi Heerachand has submitted a tip on alternate row coloring. This tip takes you one step ahead...On mouse over the row color changes...to open the document you just double click on the table row. Hope this helps someone. You can apply this script out of the box for any views that are thrown by Domino. Comments and suggestions are welcome. Cheers! Prashul



Code

var e;
//the following are the variables that control 
the height and widht
//change this as u need...can also convert ot 
global vars by declaring in jsheader and  initiliazing 
onLoad
//IMPORTANT: you have to pass the tableIndex when 
u call transformView...eg: transformView(4) etc.
docWinHeight=400;
docWinWidth=400;
/**
This function provides the alternate row coloring
 for the table generated by the view.
An event handler is also present to change the 
row color when mouse over happens
Another event handler takes care of opening the 
document in a window whenever the row is clicked
*/
function transformView(tableIndex) 
{
 var tableElements = document.getElementsByTagName('table') ;
 var table = tableElements[tableIndex] ;
  table.width = '850' ; // spreads out the table if you want it to
 table.cellSpacing = '1' ; // removes space between cells
 table.className="tabTable"

 headers = table.getElementsByTagName("th") ;
 for( i = 0; i < headers.length; i++) 
  {
   headers[i].bgColor = '0060A0' ;
  }
 //get the rows of the table we are transforming
 rows = table.getElementsByTagName("tr") ;
 var counter = 0
 //assign the title and event handlers and an id to the row
//i is set to one as the first row is th tags
 for( i = 1; i < rows.length; i++) 
 {
  rows[i].bgColor = (i % 2 ? 'FFFFFF' : 'BAD1E9') ;
  rows[i].title="Row "+i+" --> Double click to open the document"
  rows[i].id="ROW"+i
  rows[i].onmouseover = rows[i].onmouseout = showColor;

  anchors=rows[i].getElementsByTagName("A");
  if(anchors.length>0)
  {
   rows[i].ondblclick=openDblClik;
  }//end if
 }
}

function openDblClik(evt)
{
 var el = this;
 var type = "string" == typeof(window.event.type) ? 
window.event.type : evt.type;
 //var tgt = "string" == typeof(event.target) ? 
event.target : evt.target;

 if (type == "dblclick")
  {
   row=window.event.srcElement;
   rowClicked=window.event.srcElement.parentNode.id;
   
   var trTags=document.getElementsByTagName("TR");
   for (intTR=0;intTR<trTags.length;intTR++)
   {
   
    if (rowClicked!="" && rowClicked==trTags[intTR].id)
    {
     anchors=trTags[intTR].getElementsByTagName("A");
     anchor4use=findHref(anchors) //if there is an href
 returns the href else returns false
     if(anchor4use)
     {
      //alert(anchors[0].href);
      if (isLinkCategory(anchor4use.href))
      {
       //  alert("1")
       location.href=anchor4use.href
      }
      else
      {
       //alert("winHeight"+docWinHeight)
     alert("set ur window.open params")   
window.open("GIVE YOUR PARAMS HERE")       }//ending
 the category check
     }
    }
  else
  {
   //alert("2");
  var srcObj
  srcObj=window.event.srcElement;
  while (srcObj.nodeName!="TD")
  {
   //alert(srcObj.nodeName)
   srcObj=srcObj.parentNode
  }//endwhile
  rowClicked=srcObj.parentNode.id;
 
  if (rowClicked==trTags[intTR].id)
  {
   anchors=trTags[intTR].getElementsByTagName("A");
   anchor4use=findHref(anchors) //if there is an
 href returns the href   
						

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   



RELATED CONTENT
JavaScript
Trap JavaScript runtime errors in Domino Web apps
JavaScript workaround fixes Lotus Notes 8.x PostOpen event issue
Write HTML and JavaScript in Notes view rows and columns on the Web
JavaScript detects Web browser type and version in Notes/Domino 8.0.2
JavaScript creates a jump box on a Lotus Notes Web form
How to create dynamic JavaScript in Notes Domino without formulas
Trap an attachment path via the Domino file upload control field
Converting Lotus Notes views to XML documents using JavaScript
Prevent errors on iFramed pages with JavaScript
How to add keyboard functionality for Lotus Notes documents

JavaScript for Lotus Notes Domino
Trap JavaScript runtime errors in Domino Web apps
JavaScript workaround fixes Lotus Notes 8.x PostOpen event issue
Write HTML and JavaScript in Notes view rows and columns on the Web
JavaScript detects Web browser type and version in Notes/Domino 8.0.2
JavaScript creates a jump box on a Lotus Notes Web form
Top 10 Lotus Notes/Domino coding and development tips of 2008
How to create dynamic JavaScript in Notes Domino without formulas
Trap an attachment path via the Domino file upload control field
Converting Lotus Notes views to XML documents using JavaScript
Mimic Lotus Notes Domino application functionality on the Web

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 technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




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