Jump to content
JasperReports Library 7.0 is now available ×

How can I make a text field in a subreport print at the top of every page?


aklingel

Recommended Posts

I am using iReport 3.7.6 to create this report.

I have a report based off of an XML file. There is a 2-column master report and it has a detail band with a subreport.

I have a field called "Name" in the subreport. I want it to print at the top of every page. Or even at the top of every column. I have tried virtually everything I know how to do.

"Print When Detail Overflows" doesn't work, because this setting is in the detail.

I sure hope I don't need to create a subreport for every report break I want. I'll have like 4 or 5 subreports.

Is there some way to determine when the page has changed, and then use that event in a "Print When" expression?

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Does this value you want to print at the top of every page CHANGE within a single run of the report?  For example, do you have multiple subreports and each one comes up with a different value potentially or--even worse--does the value change within the subreport and you need to have the "current" value appear at the top of each page?  If not--if the subreport comes up with a single value that you need to appear at the top of every page in the report, then I would think that one of the two following solutions would work:

1. Return the value as a return parameter from the subreport and drag the main report variable it's returned in into the page header, and set the evaluation time to "Report" so that JasperReports waits for the subreport to have run before it attempts to evaluate and display this value (similar to how the second part of the "Page x of y" element works in a page footer).

2. Create a List with a subdataset that is similar to the main dataset it your subreport, but simplify it to only return the one value you need.  I have posted some tips on creating and using a List for a similar pupose (I'm printing a single date from the database at the top of every page or the top of the report, but that date really doesn't need to be part of my primary query) in this post: http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=81368&topid=81372

Since you already have the subreport working and returning the value you need, I'd start with solution #1 and try to get that to work.  Good luck!

Carl

Link to comment
Share on other sites

 Carl,

It's your "even worse" scenario. I have a single subreport, and the value is changing within the subreport. The subreport gets broken between the end of one page and the beginning of the next. I want a particular field to print when that subreport overflows onto the next page.

Think of an employee record, with a bunch of child records in other tables. There's not enough room on one page to print it all, so I want the employee's name to print at the top of the next page, so that someone randomly opening the report onto that page will know whose data they are looking at.

Link to comment
Share on other sites

aklingel,

Are you using the built-in variable $V{PAGE_COUNT}? It's the number of the detail record on the page. That works for me in simple cases. For example, I have a report that shows books grouped by year. I only want to print the year for the first book in the group. But when a group breaks across pages I want to print the year again. I use a Print When Expression like this:

$V{publish_year_COUNT} == 1 || $V{PAGE_COUNT} == 1

With your subreports I cannot tell if this will work quite as easily... but it seems that this variable ought to work for you as well.

Regards,
Matt

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