User:Eleazaros/Tables

a list of table formatting information.

Coming Soon...

Sortable Global alternating rows
This is not documented but it is built into the sortable table definition within the wikibits file. I don't really recommend using this because *ALL* tables will use it automatically and it will mess up any custom table designs that you may have but... It's there and it's available so...

In your MediaWiki:Common.css article, insert the following code. That's all it takes and, again, I do not advise doing this because it will force alternating row colors, based upon these colors, for all sortable tables on your site. /* DEFAULT "sortable" tables alternating colors. */ table tr.odd { background-color: skyblue; } table tr.even { background-color: white; }

This will set tables to alternating rows of blue and white but won't effect the header row of a table.

Alternating Rows in Tables
The code for handling this is located in both the .CSS file and in your .JS file.

In your .CSS file: table.altRows tr.odd {background-color: white;} table.altRows tr.even {background-color: skyblue;}

In your .JS file: /* Alternating row colors for tables */ function alternateRows { rw = document.getElementsByTagName("table"); for (i = 0; i < rw.length; i++) { if (rw[i].className.match("altRows")) { rows = rw[i].getElementsByTagName("tr"); for (j = 1; j < rows.length; j++) { rw2 = rows[j].getElementsByTagName("td"); for (k=0; k < rw2.length; k++) { rw2[k].className = (j % 2 == 0 ? "even" : "odd"); }            }        }    } }

addOnloadHook( function {	alternateRows }); Pretty basic and simple. Works with collapsable and sortable tables.