2004 IR Help Posted August 24, 2006 Share Posted August 24, 2006 By: Norbert - noreic Groups & New Page , a workaround for comments 2005-12-31 12:24 Hi, I would like to have a report with the a page for a chart, then a page break, and the details with data used to feed the chart. This is the report that I need: --- Chart ---- --- <page break> --- --- Details --- Now, if I have the chart in a header/footer group, at least one of details records is printed in the same page with of the group, doesn't matter the group expression I use. I can't use title and summary bands to have the chart, I am using them to show other types of information. I came out with two workarounds and I would like know if someone has a better idea them these two. The first is pretty simple. I have the chart in a group (without group expression) and set the chart size as big a page, so it is printed in its own page. I don't like this solution but it is working for now. The second is a complicated one and I hope that one can understand the following explanation. First, I create two subreports: SUBC(with the chart) and a second one called SUBD (with the details). Then, I created a main report template with two groups. I added the SUBC (with the chart) in the first group and SUBD in the second. --- Chart ---- group 1 --- Details --- group 2 The complicate part is how to force the page break... I assigned the following query for the main report: SELECT '1' as subreportnbr UNION SELECT '2' As one can see, the main report will process two records when executed. Finally, I set the following group expressions for the groups respectively. new Boolean ($V{RECORD_COUNT}.intValue() == 1) and new Boolean ($V{RECORD_COUNT}.intValue() == 2) e.g: --- Chart ---- group 1 new Boolean ($V{RECORD_COUNT}.intValue() == 1) --- Details --- group 2 new Boolean ($V{RECORD_COUNT}.intValue() == 2) So, once the main report is executed, as the first record is processed, a page break is created after the chart is printed. And finally, the details will follow in the next page. It will work if you execute the report from iReport, for example. Right now, I am trying to figure out how to set the subreports' data sources from a JAVA class in my application. Finally, I have a suggestion for JR. I think that would be a nice feature to have additional two bands that would be printed only once like the current title and summary bands, but that would have the page header/footer as the details pages. Thanks, Norberto By: Norbert - noreic RE: Groups & New Page , a workaround for comments 2006-01-01 10:44 Hi, There is a missing setting in the previous explanation. For the groups in the main report, the "print when expression" must be set as new Boolean ($V{RECORD_COUNT}.intValue() == 1) or new Boolean ($V{RECORD_COUNT}.intValue() == 2) depend on the group. (I can't explain why, but it is required, otherwise the chart and the details are printed in the same page) Also, I was able to execute it from a Java application. (I am using iReport to edit my reports). First, in the subreports, change the connection to a "JRDataSourceProvider" , class "net.sf.jasperreports.engine.JRResultSetDataSource". So, the subreports are expecting to receive a JRDataSource. In the main report, for the subreports settings, set the connection/datasource expression as "Use datasource expression", and set a parameter name for that. e.g: $P{MyDataSourceChart} for the chart subreport and $P{MyDataSourceDetails} for the details subreport. Important: You have to create these parameters in the main report, in my case I created both and set the parameter class type as "net.sf.jasperreports.engine.JRResultSetDataSource" for each one. Finally, in the JAVA application, create the JRDataSource and pass it as parameter. e.g: parameters.put("MyDataSourceChart", datasource1) parameters.put("MyDataSourceDetails", datasource2) In my case, even that the datasource1 and datasource2 have the same result set, I had to create and pass it twice as two different instances. I tried to have just one data source for both subreports, but at the end, the second subreports neved displayed any detail information. I believe that it happened because in at point of the report processing, the cursor is positioned in its last record, so the subreport believes there isn't more records to display. Thanks, Norbert Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now