Jump to content
Changes to the Jaspersoft community edition download ×

Changing the background color of Crosstab cell


Browndog

Recommended Posts

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I've got an idea on how to do this but I cant make it work.

 

I now what it so when the leaveCode = A/L the cell is green and S/L the cell is yellow

 

 

In the <crosstabCell> I want the color to change I add a <rectangle> and I use the <printWhenExpression> tag and different colored.

 

The problem I get is "Field not found : leaveCode" it seems the leaveCode field is not avaliable within the crosstab cell, is there a way around this?

 

Code:
<crosstabCell width="50" height="25">					<cellContents>						<box>							<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>						</box>						<rectangle>							<reportElement mode="Opaque" x="0" y="0" width="50" height="25" backcolor="#FF0000">								<printWhenExpression><![CDATA[new Boolean( $F{leaveCode}.equals("A/L")]]></printWhenExpression>							</reportElement>						</rectangle>						<rectangle>							<reportElement mode="Opaque" x="0" y="0" width="50" height="25" backcolor="#00FF00">								<printWhenExpression><![CDATA[new Boolean( $F{leaveCode}.equals("S/L") )]]></printWhenExpression>							</reportElement>						</rectangle>						<textField hyperlinkType="None">							<reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/>							<textElement/>							<textFieldExpression class="java.lang.Double"><![CDATA[$V{hoursMeasure}]]></textFieldExpression>						</textField>					</cellContents>				</crosstabCell>
Link to comment
Share on other sites

Hi,

 

I think you need to understand how crosstabs work. In general, crosstabs display aggregated values that we call measures. These measures are variables that aggregate data coming from individual field values.

In a crosstab you can only display measure values, not field values. Inside a crosstab, field values are irrelevant.

Within a crosstab cell level expression, field references are not even available because they do not make any sense.

Just like in a cell crosstab you can only display measure values, you can only used measure values in the printWhenExpression.

I hope this helps.

Teodor

 

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...