Jump to content
Changes to the Jaspersoft community edition download ×

CROSSTAB - row counting & background filling


Krac

Recommended Posts

Hello, JasperReports-people!

 

Is there any possibility to alternatively-color/fill the rows background for a crosstab, depending on the current row number in the crosstab?

 

I would like a condition that resembles the following:

 

new Boolean(($V{ROW_COUNT}.intValue()%3) == 0)

 

where ROW_COUNT is the number of rows in the crosstab.

 

 

Example: 1st row is RED, second is YELLOW, third is BLUE (Hai Romania!) or RED-WHITE-GREEN (Viva Italia!) and so on...

 

Is there any BUILT-IN variable that automatically counts the rows for a crosstab?

 

TIA,

 

Razvan

 

Post edited by: Krac, at: 2007/02/21 14:03

Post edited by: Krac, at: 2007/02/21 14:03

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

The ROW_COUNT and COLUMN_COUNT variables are available in crosstabs. One can achieve alternate colors for crosstab rows using these variables and conditional styles.

 

The OrdersReport sample found in the JasperReports project package under demo/samples/crosstabs illustrates this.

 

HTH,

Lucian

Link to comment
Share on other sites

  • 10 months later...
  • 1 month later...

Hi,

 

I am also doing the alternate color. Is there any other way to do it. As in without using ROW_COUNT?

 

In my scenario ROW_COUNT is not working. What i have 2 rowGroups. The row count is determined by the inner one, and for the outer one i want alternate color.

 

I'have tried condition style. But since i am getting odd in all the case, the color for outer row group is coming out to be same.

 

A1 B1 <grey>

- B2 <white>

- Total <blue>

A2 B1 < grey>

- B2 < white>

 

In this both A1 and A2 are getting same color, as row_count for them is 1 and 3. How can i get them to have different color?

 

Thanks,

Jyoti

 

Code:
    <style name="detailCellStyle">
<conditionalStyle>
<conditionExpression>$V{ROW_COUNT}.intValue() % 2 == 1 ? Boolean.TRUE : Boolean.FALSE</conditionExpression>
<style backcolor="#DDDAC0" mode="Opaque" forecolor="black"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression>$V{ROW_COUNT}.intValue() % 2 != 1 ? Boolean.TRUE : Boolean.FALSE</conditionExpression>
<style backcolor="white" mode="Opaque" forecolor="black"/>
</conditionalStyle>
</style>
Link to comment
Share on other sites

  • 3 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...