Tags:
create new tag
view all tags

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

TWiki version: TWikiRelease04x00x03
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories:  

-- VickiBrown - 26 Jun 2006

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

You can set variables in the WebPreferences and use them in the table. Example:

  • Set ST_YELLOW =
     Yellow led Pending
  • Set ST_GREEN =
     Green led Done
  • Set ST_RED =
     Red led Overdue

| *Item* | *Status* |
| Foo | %ST_YELLOW% |
| Bar | %ST_GREEN% |
| Goo | %ST_RED% |

Item Status
Foo
 Yellow led Pending
Bar
 Green led Done
Goo
 Red led Overdue

-- 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 frown

-- 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

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2009-11-05 - VickiBrown
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.