Opened 5 years ago
Last modified 3 years ago
#7199 new enhancement
Colour/style individual cells in ticket report
| Reported by: | Matt Young | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | unscheduled |
| Component: | report system | Version: | 0.10.4 |
| Severity: | normal | Keywords: | |
| Cc: | |||
| Release Notes: | |||
| API Changes: | |||
Description
Trac reports allow you to apply a colour or style to each row of the results, but not to individual cells in the row. It would be very helpful to allow different cells in the same row to be coloured differently. Then we could have, eg, one set of background colours for the "Priority" field and another for the "Status" field.
Attachments (0)
Change History (5)
comment:1 Changed 5 years ago by sid
comment:2 Changed 5 years ago by cboos
- Resolution set to worksforme
- Status changed from new to closed
See also #6158.
comment:3 Changed 5 years ago by Matt Young
- Resolution worksforme deleted
- Status changed from closed to reopened
The solution proposed above doesn't actually work. The point is that, because of the way the __style__ attribute of a query is applied, you can't use CSS to make a colour apply to a single cell. The style gets inserted directly in the TR tag. Eg if your query contains something like the following:
SELECT ...
(CASE priority
WHEN 'major' THEN 'background: #FF6666'
WHEN 'normal' THEN 'background: #FFFFCC'
WHEN 'minor' THEN 'background: #FFFFFF'
ELSE 'background: #33FFFF'
END)
AS __style__
FROM ...
then you end up with HTML like this:
<tr class="even" style="background: #FF6666;"> ... <td class="version">0.10.2</td> <td class="severity">major</td> <td class="owner">jonas</td> ... </tr> <tr class="even" style="background: #FFFFFF;"> ... <td class="version">0.10.2</td> <td class="severity">minor</td> <td class="owner">jonas</td> ... </tr>
What we need is for some way in the query to be able to change the class name (rather than the inline style) of each table row. Then, as you say, we would be able to do per-cell colouring with CSS.
This is important to allow different cells in the same row to have different colours — eg you might very well want one colour for severity and another for priority.
comment:4 Changed 5 years ago by rblank
- Milestone set to 2.0
- Owner mgood deleted
- Status changed from reopened to new
comment:5 Changed 3 years ago by cboos
- Milestone changed from 2.0 to unscheduled
Milestone 2.0 deleted



This is easy to do with CSS. Each table cell has a defined class, so you just set colors for the classes you want to change.
Here's an example HTML row from a report:
<tr class="color3-odd"> <td class="type">defect</td> <td class="ticket"> <a title="View ticket" href="/ticket/3868">#3868</a> </td> <td class="summary"> <a title="View ticket" href="/ticket/3868">Post action and fastcgi 'Broken pipe' problem.</a> </td> <td class="component">general</td> <td class="version">0.10.2</td> <td class="severity">normal</td> <td class="owner">jonas</td> <td class="status">new</td> <td class="lastmodified">40 days</td> <td class="chgs_auths">15 by 9</td> </tr>I don't think this type of color styling is widely useful or desired. And it is quite easy to change for your site. Propose closing as worksforme.