Jump to content
We've recently updated our Privacy Statement, available here ×

dynamic report column


sreepriyar

Recommended Posts

Hi all,

 

I have a particular field which if it has some value, I should create a new column and display the details in that. If it does not contain the details, I should not display the column. Is there any way to handle this in Jasper report?

 

Lets say I have 2 columns in my report. (field1 and field2)

 

IF (field1.equals(showme), then

create a new column(field3) and display field1details,

else proceed in same manner.

 

case 1: field1!=showme

display Field1 Field2

case 2 : field1==showme

display Field1 Field3 Field2

 

Can I do this?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

As I understand it, you need the column to change based on data you are getting from some datasource (database, javabean, etc.). I wouldn't make the column field static. Just make it a regular textField. In the textFieldExpression you can add your condition (I am assuming it is a string).

Code:

$F{someDataField}.equalsIgnoreCase( "data" ) ?
"Column Text"
:
""

 

You might have to play with this to get the formatting to work out right on your report; especially if other columns might be position the same way.

 

Calvin

Link to comment
Share on other sites

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