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

Is it possible to use a text field's location in a print when expression?


pauljschofield

Recommended Posts

I'm trying to hide/display fields, based on values that come back from the report's main query. Is it possible to find (and use) a field's X coordinate in an expression?

So, if the report query returns $F{START_POSITION} and $F{END_POSITION} as 20 and 40 respectively, I want to display the fields that are between X=20 and X=40 and hide all the others.

The X value is available via the properties pane for all fields, but how do I reference it in an expression? Can that be done?

Paul

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You need to write a print when expression for each textfield and use the static value of the X-coordinate in each expression. For instance, if the textfield has X = 20, the related print when expression should look like:

$F{START_POSITION} <= 20 && $F{END_POSITION} >= 20[/code]

 

Link to comment
Share on other sites

That was a quick reponse. The method you've given is what I'm doing right now, but I was hoping to future proof things by using the field properties. The report layout might change in future, and editing all the print when expressions again will be painful. If that's how it works though, that's how it works. Thanks again.

 

 

 

 

 

 

Link to comment
Share on other sites

To do what you want, you'll need to create your own program using JasperReports library. Jaspersoft Studio just generates a static jrxml file with static x/y coordinates. This is just a limitation of Jaspersoft Studio and not that of JasperReports library itself.

Link to comment
Share on other sites

Thanks Hozawa,

 

I was hoping that the functionality was already there. When you move fields around on screen, the boxes become red when they collide, so Studio does know where things are when you layout the canvas. It's just a pity the functionality isn't more widely available.

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