Question
Is it "possible" to set the background color of an individual / single cell of a table that uses TWiki formatting (with the EDITTABLEPlugin or TABLEPlugin)? Or do I have to resort to pure HTML? I understand how to change the row color. I want to override that on an individual cell basis.
Reason: in Project tables, e.g., it is often convenient to color code status cells, red, green, yellow, based on whether they are in progress, halted, etc.
Environment
--
VickiBrown - 26 Jun 2006
Answer
If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.
You can set variables in the
WebPreferences and use them in the table. Example:
- Set ST_YELLOW =

Pending
- Set ST_GREEN =

Done
- Set ST_RED =

Overdue
| *Item* | *Status* |
| Foo | %ST_YELLOW% |
| Bar | %ST_GREEN% |
| Goo | %ST_RED% |
--
PeterThoeny - 26 Jun 2006
If you need the whole cell background, not only the text background you can use HTML but it doesn’t have to be a pure HTML table, you can use a mix so wiki table functionality (e.g. sorting) is not lost.
| *Col1* | *Col2* | *Col3* |
| fila uno columna uno | fila uno columna dos | fila uno columna tres |
| fila dos columna uno </td><td bgcolor='#FF0000'> fila dos columna dos | fila dos columna tres |
| fila tres columna uno | fila tres columna dos | fila tres columna tres |
| Col1 |
Col2 |
Col3 |
| fila uno columna uno |
fila uno columna dos |
fila uno columna tres |
| fila dos columna uno | fila dos columna dos |
fila dos columna tres |
| fila tres columna uno |
fila tres columna dos |
fila tres columna tres |
--
EnriqueCadalso - 01 Jul 2007
I edited the above examples to include verbatim code samples.
--
ClifKussmaul - 16 Apr 2008
Does anyone know how to do this with the
first cell of the table? I'm not having any luck making that work...
--
VickiBrown - 13 Jun 2008
| *Col1* | *Col2* | *Col3* |<nop><tr class="twikiTableOdd"><td bgcolor='#FF0000'> fila uno columna uno | fila uno columna dos | fila uno columna tres | |
| fila dos columna uno </td><td bgcolor='#FFFF00'> fila dos columna dos | fila dos columna tres | |
| fila tres columna uno | fila tres columna dos | fila tres columna tres | |
| Col1 |
Col2 |
Col3 |
|
| fila uno columna uno |
fila uno columna dos |
fila uno columna tres |
|
| fila dos columna uno | fila dos columna dos |
fila dos columna tres |
|
| fila tres columna uno |
fila tres columna dos |
fila tres columna tres |
|
Doesn't work properly due to the greediness of the TML table headers
--
FranzJosefGigler - 14 Jun 2008
I edited the above example to include verbatim code. It seems to work now...
FYI: These days, we color based on content, using
JavaScript. See
http://cfcl.com/twiki/bin/view/Learn/Tut/TWikiTutColorTable for details.
It's also possible, in more recent versions of TABLE, to color columns using CSS.
--
VickiBrown - 2009-11-05