1 # <a name="Table Plugin"></a> Table Plugin
3 Gives extra control of table display:
6 - Changing table properties like border width, cell spacing and cell padding
7 - Changing background color for header cells
8 - Changing background color for data cells - colors can _alternate_
9 - Behaviour can be specified for a specific table using %TABLE\{...\}% or with global preferences
11 ## <a name="%TOPIC% Global Settings"></a> %TOPIC% Global Settings
13 Plugin settings are stored as preferences variables. To reference a plugin setting write <code>**%<plugin>\_<setting>%**</code>, for example, <code>**%INTERWIKIPLUGIN\_SHORTDESCRIPTION%**</code>
15 - One line description, shown in the [[TextFormattingRules]] topic:
16 - Set SHORTDESCRIPTION = Control attributes of tables and sorting of table columns
18 - Set DEBUG to 1 to get debug messages in `data/debug.txt`. Default: `0`
21 - Table border width. Default: 1
24 - Table cell padding. Default: 0
27 - Table cell spacing. Default: 1
30 - Vertical alignment of cells. Set to: `top`, `middle`, `bottom` or `baseline`; default: (empty)
33 - Table header cell alignment. Set to: `left`, `center`, `right` or `justify`; default: (empty)
36 - Table data cell alignment. Set to: `left`, `center`, `right` or `justify`; default: (empty)
39 - Background color of header cells ('\*'s around text). Choose one of the [[StandardColors]]. Default: <span>\#99CCCC</span>
42 - Text color of header cells ('\*'s around text). Default: not specified, e.g. determined by the browser
45 - Background color of table rows, two alternate colors. Default: <span>\#FFFFCC</span>, <span>\#FFFFFF</span>
46 - Set DATA\_BG = #FFFFCC, #FFFFFF
48 - Text color of table rows, alternate colors. Default: not specified, e.g. determined by the browser
52 - #Set SORT = attachments
56 ## <a name="Sorting"></a> Sorting
58 Click on column heading text to sort by a column. Initial column will be sorted in descending order, click again to get ascending order. The type of data in the cell is determined automatically:
62 - dd-MMM-YY or dd-MM-YYYY (can be / or space in place of -)
63 - MMM is Jan, Feb, etc
64 - number is digits, with optional decimal point
65 - otherwise treated as text
67 ## <a name="Per Table Settings"></a> Per Table Settings
69 On line before the table use `%TABLE{...}%`:
71 <table border="1" cellpadding="0" cellspacing="0" style="border-width: 1px">
73 <th bgcolor="#6b7f93" maxcols="0" style=""><a href="http://localhost?sortcol=0;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Argument</font></a></th>
74 <th bgcolor="#6b7f93" maxcols="0" style=""><a href="http://localhost?sortcol=1;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Comment</font></a></th>
75 <th bgcolor="#6b7f93" maxcols="0" style=""><a href="http://localhost?sortcol=2;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Example</font></a></th>
78 <td bgcolor="#ecf2f8" style=""><code>sort</code></td>
79 <td bgcolor="#ecf2f8" style=""> Set table sorting <code>on</code> or <code>off</code></td>
80 <td bgcolor="#ecf2f8" style=""><code>sort="on"</code></td>
83 <td bgcolor="#ffffff" style=""><code>initsort</code></td>
84 <td bgcolor="#ffffff" style=""> Column to sort initially (1 to number of columns) </td>
85 <td bgcolor="#ffffff" style=""><code>initsort="2"</code></td>
88 <td bgcolor="#ecf2f8" style=""><code>initdirection</code></td>
89 <td bgcolor="#ecf2f8" style=""> Initial sorting direction for <code>initsort</code>, set to <code>up</code> or <code>down</code></td>
90 <td bgcolor="#ecf2f8" style=""><code>initsort="down"</code></td>
93 <td bgcolor="#ffffff" style=""><code>headerbg</code></td>
94 <td bgcolor="#ffffff" style=""> Header cell background colour. Choose one of the [[TWiki/StandardColors]]</td>
95 <td bgcolor="#ffffff" style=""><code>headerbg="#99CCCC"</code></td>
98 <td bgcolor="#ecf2f8" style=""><code>headercolor</code></td>
99 <td bgcolor="#ecf2f8" style=""> Header cell text colour </td>
100 <td bgcolor="#ecf2f8" style=""><code>headercolor="#0000CC"</code></td>
103 <td bgcolor="#ffffff" style=""><code>databg</code></td>
104 <td bgcolor="#ffffff" style=""> Data cell background colour, a comma separated list. Specify <code>"none"</code> for no colour, that is to use the colour/background of the page the table is on. </td>
105 <td bgcolor="#ffffff" style=""><code>databg="#C8CB8F, #DBDDB5"</code></td>
108 <td bgcolor="#ecf2f8" style=""><code>datacolor</code></td>
109 <td bgcolor="#ecf2f8" style=""> Data cell text colour, a comma separated list </td>
110 <td bgcolor="#ecf2f8" style=""><code>datacolor="#0000CC, #000000"</code></td>
113 <td bgcolor="#ffffff" style=""><code>tableborder</code></td>
114 <td bgcolor="#ffffff" style=""> Table border width (pixels) </td>
115 <td bgcolor="#ffffff" style=""><code>tableborder="2"</code></td>
118 <td bgcolor="#ecf2f8" style=""><code>cellpadding</code></td>
119 <td bgcolor="#ecf2f8" style=""> Cell padding (pixels) </td>
120 <td bgcolor="#ecf2f8" style=""><code>cellpadding="0"</code></td>
123 <td bgcolor="#ffffff" style=""><code>cellspacing</code></td>
124 <td bgcolor="#ffffff" style=""> Cell spacing (pixels) </td>
125 <td bgcolor="#ffffff" style=""><code>cellspacing="3"</code></td>
128 <td bgcolor="#ecf2f8" style=""><code>valign</code></td>
129 <td bgcolor="#ecf2f8" style=""> Vertical alignment of cells, set to <code>top</code>, <code>middle</code>, <code>bottom</code> or <code>baseline</code></td>
130 <td bgcolor="#ecf2f8" style=""><code>valign="top"</code></td>
133 <td bgcolor="#ffffff" style=""><code>headeralign</code></td>
134 <td bgcolor="#ffffff" style=""> Header cell alignment, set to <code>left</code>, <code>center</code>, <code>right</code> or <code>justify</code>. Overrides individual cell settings </td>
135 <td bgcolor="#ffffff" style=""><code>headeralign="left"</code></td>
138 <td bgcolor="#ecf2f8" style=""><code>dataalign</code></td>
139 <td bgcolor="#ecf2f8" style=""> Data cell alignment, set to <code>left</code>, <code>center</code>, <code>right</code> or <code>justify</code>. Overrides individual cell settings </td>
140 <td bgcolor="#ecf2f8" style=""><code>dataalign="center"</code></td>
144 All default to the global setting
146 ## <a name="Example"></a> Example
148 Line before table: `%TABLE{ sort="on" tableborder="0" cellpadding="1" cellspacing="3" headerbg="#000099" headercolor="#FFFFCC" databg="#C8CB8F, #DBDDB5" }%`
150 <table border="0" cellpadding="1" cellspacing="3" style="border-width: 0px">
152 <th bgcolor="#000099" maxcols="0" style=""><a href="http://localhost?sortcol=0;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#FFFFCC">Num</font></a></th>
153 <th bgcolor="#000099" maxcols="0" style=""><a href="http://localhost?sortcol=1;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#FFFFCC">Status</font></a></th>
154 <th bgcolor="#000099" maxcols="0" style=""><a href="http://localhost?sortcol=2;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#FFFFCC">Action</font></a></th>
155 <th bgcolor="#000099" maxcols="0" style=""><a href="http://localhost?sortcol=3;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#FFFFCC">Who</font></a></th>
156 <th bgcolor="#000099" maxcols="0" style=""><a href="http://localhost?sortcol=4;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#FFFFCC">When</font></a></th>
157 <th bgcolor="#000099" maxcols="0" style=""><a href="http://localhost?sortcol=5;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#FFFFCC">Progress</font></a></th>
160 <td bgcolor="#C8CB8F" style=""> 1 </td>
161 <td bgcolor="#C8CB8F" style=""> C </td>
162 <td bgcolor="#C8CB8F" style=""> Chose new colours </td>
163 <td bgcolor="#C8CB8F" style=""> John </td>
164 <td bgcolor="#C8CB8F" style=""> 1-Dec-02 </td>
165 <td bgcolor="#C8CB8F" style=""> </td>
168 <td bgcolor="#DBDDB5" style=""> 2 </td>
169 <td bgcolor="#DBDDB5" style=""> X </td>
170 <td bgcolor="#DBDDB5" style=""> Release </td>
171 <td bgcolor="#DBDDB5" style=""> John </td>
172 <td bgcolor="#DBDDB5" style=""> 1-Apr-02 </td>
173 <td bgcolor="#DBDDB5" style=""> </td>
176 <td bgcolor="#C8CB8F" style=""> 3 </td>
177 <td bgcolor="#C8CB8F" style=""> </td>
178 <td bgcolor="#C8CB8F" style=""> Get feedback </td>
179 <td bgcolor="#C8CB8F" style=""> Anne </td>
180 <td bgcolor="#C8CB8F" style=""> 1-Feb-02 </td>
181 <td bgcolor="#C8CB8F" style=""> </td>
184 <td bgcolor="#DBDDB5" style=""> 12 </td>
185 <td bgcolor="#DBDDB5" style=""> C </td>
186 <td bgcolor="#DBDDB5" style=""> Spec error handling </td>
187 <td bgcolor="#DBDDB5" style=""> Jack </td>
188 <td bgcolor="#DBDDB5" style=""> 1-Dec-02 </td>
189 <td bgcolor="#DBDDB5" style=""> </td>
192 <td bgcolor="#C8CB8F" style=""> 5 </td>
193 <td bgcolor="#C8CB8F" style=""> </td>
194 <td bgcolor="#C8CB8F" style=""> Abc </td>
195 <td bgcolor="#C8CB8F" style=""> John </td>
196 <td bgcolor="#C8CB8F" style=""> </td>
197 <td bgcolor="#C8CB8F" style=""> </td>
201 ## <a name="Plugin Installation Instructions"></a> Plugin Installation Instructions
203 **Note:** You do not need to install anything on the browser to use this plugin. Below installation instructions are for the administrator who needs to install this plugin on the TWiki server.
205 - Download the ZIP file from the Plugin web (see below)
206 - Unzip <code>**%TOPIC%.zip**</code> in your twiki installation directory. Content: <table border="1" cellpadding="0" cellspacing="0" style="border-width: 1px">
208 <th bgcolor="#6b7f93" maxcols="0" style=""><a href="http://localhost?sortcol=0;table=3;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">File:</font></a></th>
209 <th bgcolor="#6b7f93" maxcols="0" style=""><a href="http://localhost?sortcol=1;table=3;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Description:</font></a></th>
212 <td bgcolor="#ecf2f8" style=""><code><b>data/TWiki/%TOPIC%.txt</b></code></td>
213 <td bgcolor="#ecf2f8" style=""> Plugin topic </td>
216 <td bgcolor="#ffffff" style=""><code><b>data/TWiki/%TOPIC%.txt,v</b></code></td>
217 <td bgcolor="#ffffff" style=""> Plugin topic repository </td>
220 <td bgcolor="#ecf2f8" style=""><code><b>lib/TWiki/Plugins/%TOPIC%.pm</b></code></td>
221 <td bgcolor="#ecf2f8" style=""> Plugin Perl module </td>
224 <td bgcolor="#ffffff" style=""><code><b>pub/TWiki/%TOPIC%/diamond.gif</b></code></td>
225 <td bgcolor="#ffffff" style=""> Diamond symbol </td>
228 <td bgcolor="#ecf2f8" style=""><code><b>pub/TWiki/%TOPIC%/down.gif</b></code></td>
229 <td bgcolor="#ecf2f8" style=""> Down arrow </td>
232 <td bgcolor="#ffffff" style=""><code><b>pub/TWiki/%TOPIC%/up.gif</b></code></td>
233 <td bgcolor="#ffffff" style=""> Up arrow </td>
236 - Test if the plugin is correctly installed:
237 - Check above example if the table renders as expected
238 - Try click on heading to sort. Other tables should also be sortable
240 ## <a name="Plugin Info"></a> Plugin Info
242 <table border="1" cellpadding="0" cellspacing="0" style="border-width: 1px">
244 <td align="right" bgcolor="#ecf2f8" style=""> Plugin Author: </td>
245 <td bgcolor="#ecf2f8" style="">[[TWiki/JohnTalintyre]], [[TWiki/PeterThoeny]]</td>
248 <td align="right" bgcolor="#ffffff" style=""> Plugin Version: </td>
249 <td bgcolor="#ffffff" style=""> 09 Dec 2002 </td>
252 <td align="right" bgcolor="#ecf2f8" style=""> Change History: </td>
253 <td bgcolor="#ecf2f8" style=""> </td>
256 <td align="right" bgcolor="#ffffff" style=""> 09 Dec 2002: </td>
257 <td bgcolor="#ffffff" style=""> PTh: Added headercolor and datacolor parameters </td>
260 <td align="right" bgcolor="#ecf2f8" style=""> 05 Jun 2002: </td>
261 <td bgcolor="#ecf2f8" style=""> PTh: Added "none" value to databg parameter (suggested by TWiki:Main/TaitCyrus); fixed sorting by stripping HTML tags, removing links and making sort ignore case (suggested by TWiki:Main/ShawnBradford) </td>
264 <td align="right" bgcolor="#ffffff" style=""> 13 Mar 2002: </td>
265 <td bgcolor="#ffffff" style=""> PTh: Added TWiki:Main/ShawnBradford 's initsort and initdirection </td>
268 <td align="right" bgcolor="#ecf2f8" style=""> 12 Mar 2002: </td>
269 <td bgcolor="#ecf2f8" style=""> PTh: Added valign, headeralign and dataalign; fixed bug of swapped cellpadding/cellspacing; fixed warning of uninitialized value </td>
272 <td align="right" bgcolor="#ffffff" style=""> 05 Jan 2002: </td>
273 <td bgcolor="#ffffff" style=""> PTh: Fixed sorting bug of cells with leading white space </td>
276 <td align="right" bgcolor="#ecf2f8" style=""> 06 Dec 2001: </td>
277 <td bgcolor="#ecf2f8" style=""> PTh: Fixed date sorting bug <br /> 03 Dec 2001 PTh: Fixed sort="off" bug and more </td>
280 <td align="right" bgcolor="#ffffff" style=""> 29 Nov 2001: </td>
281 <td bgcolor="#ffffff" style=""> PTh: Fixed Perl warnings </td>
284 <td align="right" bgcolor="#ecf2f8" style=""> 16 Nov 2001: </td>
285 <td bgcolor="#ecf2f8" style=""> PTh: Added table border, cell spacing, cell padding, gif files </td>
288 <td align="right" bgcolor="#ffffff" style=""> 07 Oct 2001: </td>
289 <td bgcolor="#ffffff" style=""> JT: Initial version </td>
292 <td align="right" bgcolor="#ecf2f8" style=""> CPAN Dependencies: </td>
293 <td bgcolor="#ecf2f8" style=""> none </td>
296 <td align="right" bgcolor="#ffffff" style=""> Other Dependencies: </td>
297 <td bgcolor="#ffffff" style=""> none </td>
300 <td align="right" bgcolor="#ecf2f8" style=""> Perl Version: </td>
301 <td bgcolor="#ecf2f8" style=""> 5.0 </td>
304 <td align="right" bgcolor="#ffffff" style=""> Plugin Home: </td>
305 <td bgcolor="#ffffff" style=""><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%</a></td>
308 <td align="right" bgcolor="#ecf2f8" style=""> Feedback: </td>
309 <td bgcolor="#ecf2f8" style=""><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev</a></td>
313 **_Related Topics:_** [[TWikiPreferences]], [[TWikiPlugins]], [[StandardColors]]
315 -- [[JohnTalintyre]] - 07 Oct 2001 <br /> -- [[PeterThoeny]] - 09 Dec 2002 <br />