Page 1 of 1
Color crosstab report lines
Posted: Thu Sep 29, 2022 8:09 pm
by marisoft
In a crosstab report I am color coding the values in the cross tab with code in Cell_rendered event like this:
if ($this->RowType == ROWTYPE_DETAIL) {
if ($percent > 89){
$CellAttrs["style"] = "background-color: red; color: white; text-align: right;";
}
}
But I would like to NOT color the lines total amount.
How do I avoid this?
Tia
/Poul
Re: Color crosstab report lines
Posted: Thu Sep 29, 2022 8:43 pm
by arbei
You may check the total lines by, e.g.
if ($this->RowTotalType == ROWTOTAL_GROUP) { ... } // Group total
if ($this->RowTotalType == ROWTOTAL_PAGE) { ... } // Page Total
if ($this->RowTotalType == ROWTOTAL_GRAND) { ... } // Grand total
Re: Color crosstab report lines
Posted: Thu Sep 29, 2022 9:58 pm
by marisoft
Thanks, but it is not total lines, but the last cell in the detail line containing the total that I do not want to color.
In dev-tools I see this:
<td class="ew-table-row ew-table-last-col" style="background-color: lightgreen; text-align: right;">
<ul class="list-unstyled ew-crosstab-values">
<li><span>199</span></li>
<li><span>6</span></li>
<li><span>33</span></li>
</ul>
</td>
so I need to detect within RowType == ROWTYPE_DETAIL that it is last column.
Re: Color crosstab report lines
Posted: Thu Sep 29, 2022 10:04 pm
by arbei
marisoft wrote:
<td class="ew-table-row ew-table-last-col" ...
So you may try to check if you can find this CSS class in the $CellAttrs
argument of the event, you can var_dump($CellAttrs)
to see the contents first.
Re: Color crosstab report lines
Posted: Thu Sep 29, 2022 11:19 pm
by marisoft
For a detail line with 7 numbers, last on being the total I am getting this with var_dump($CellAttrs):
array(1) { ["class"]=> string(0) "" } string(3) array(1) { ["class"]=> string(0) "" } string(3) array(1) { ["class"]=> string(0) "" } string(3) array(1) { ["class"]=> string(0) "" } string(3) array(1) { ["class"]=> string(0) "" } string(3)
array(1) { ["class"]=> string(0) "" } string(3) array(1) { ["class"]=> string(0) "" }
Not shure what to make of that.
/Poul
Re: Color crosstab report lines
Posted: Fri Sep 30, 2022 9:44 am
by arbei
So the CSS class is not added by server side code, then you may simply add your CSS under HTML -> Styles -> User tab to override the color, e.g.
.ew-table-last-col {
background-color: white;
}
Re: Color crosstab report lines
Posted: Fri Sep 30, 2022 1:31 pm
by marisoft
Fantastic.
That did it :-)
Re: Color crosstab report lines
Posted: Fri Sep 30, 2022 2:25 pm
by marisoft
Sorry I was a bit to fast to conclude her - tested with wrong values.
Even though I have the user CSS style for .ew-table-last-col set as suggested, it seem that my code in Cell_rendered event overrides it.
So this color is stil being applied:
if ($this->RowType == ROWTYPE_DETAIL) {
if ($percent > 89){
$CellAttrs["style"] = "background-color: red; color: white; text-align: right;";
}
}