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

Rectangle around subreport


helmut

Recommended Posts

Hi folks,

I need to draw a rectangle (with radius) around a subreport, which I have managed by putting the rectangle and the subreport into an element group of the main report and setting the correct strecht type. This works fine. My problem though is that the subreport can be empty. In this case the rectangle is still drawn, but it should also not be printed!!! :( Does anybody have a solution for this problem?

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

A slightly ugly solution that comes to mind is to create an intermediate subreport that has only your rectangle and the original subreport. It should have the same datasource as the original subreport, and therefore if the datasource is empty the intermediate subreport (and the therefore the rectangle) won't be shown.

 

Alternatively, if you have a way of determining the size of your datasource you could use that information in the printWhenExpression of the rectangle.

Link to comment
Share on other sites

Hello Telos,

Thank you for your quick reply! I have implemented your the solution using an 'intermediate' subreport. This works fine. (and at the same time solves some other issues)

Just out of interest: How could I determined the size of my data source in a 'printWhenExpression'. Do I have to use a scriptlet or can I solve this with a 'conventional' expression?

 

Thank you again for your support!

Regards

Helmut

Link to comment
Share on other sites

Do you use an implementation of JRDataSource? If so, you could extend it to your own and just make a method like this:

 

Code:
public Integer getRecordCount(){
return this.recordsObjectArrayListMapOrWhatEver.size();
}

 

in your PrintWhenExpression you could easily use:

 

Code:
[code]new Boolean($P{MySubReportDataSource}.getRecordCount().intValue() >0)

 

So I did with my FilterableDTODatasource. WOrks fine!! Just give it a try.

 

hth

C-Box

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