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

Remove Line When Blank?


marcus1981

Recommended Posts

Hello,

 

I want to be able to remove a line in my report if its value is blank. For example, an address may have the parameters: address1, address2, address3, city, postcode. In my report this may be displayed as:

 

$P{address1}

$P{address2}

$P{address3}

$P{city}

$P{postcode}

 

Now this works fine. However, if say address3 comes back as null or blank i get a gap between address2 and city. Is there a way of removing such a line if this is to be the case? I've had a play with things like Remove Line When Blank etc but am having no joy :(

 

Any advice would be greatly appreciated!

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

As far as I understand it, iReport will not do this for you -

 

If you wanted to get super techical, you could do two different sets of lables, etc and use print when expressions to know which one to display. For example, print 2_line_address_version when address3 is null

print 3_line_address_version when address3 is not null

 

Any way you do it, you'll have some whitespace at the bottom or between address and city.

 

Someone please correct if wrong.

Link to comment
Share on other sites

gombs is on the right track but hasn't explained it clearly...

 

 

The Remove Line When Blank setting is working properly for you, it's just that the following fields are not shifting up. This is usually caused by their Position Type being set to "FixRelativeToTop".

 

 

Only the first element in the vertical stack should be set to FixRelativeToTop, the rest of the elements in the band should be set to "Float" so that they can be moved up if any empty element is removed.

Link to comment
Share on other sites

  • 2 weeks later...

Thanks guys i've got this working now :)

 

However i now have another related query.

 

Give this setup:

 

$F{Name}

$F{Add1}

$F{Add2}

$F{City}

$F{Postcode}

 

$F{Telephone}

 

Ok so i've not got it to shift up if say add2 is blank. However is there a way to make say telephone FIXED in its position?

Link to comment
Share on other sites

Hi yes your totally correct.

 

I'm sorry i didn't explain myself very well. By ticking keep fixed to top etc will keep it fixed in position in relation to the other items. However i think my problem may be more with the band height. When items are removed the band heigh seems to shrink. Is there a way of ensuring the band heigh stays the same regardless of this?

 

Basically I'm trying to print out some shipping labels. If i remove the blank lines all the items move up. This is causing the band height to shrink and then the labels are out of position. So is there a way to force the band height to remain constant but allow the items inside to remove when blank etc?

 

I really appreciate the advice given on this :)

Link to comment
Share on other sites

This might sound really, really dumb but it should work (sorry, unable to test it at the moment).

 

 

Build yourself a rectangle element that is the same height as the minimum band height that you need. Set its borders to "none" and its foreground and background colors to white. Make sure you "Send it to back" so that it doesn't get in the way.

 

 

Now everything can float all it likes, but the band height should stay fixed.

 

 

I can't understand why the band height would shrink if you have a Text Field "FixedRelativeToTop/Bottom" at the bottom of the band. I'll check it out on Monday.

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