javalogan Posted July 17, 2015 Share Posted July 17, 2015 At the moment I have something like the following:Grouped by CHILDRENData sorted alphabetically (top to bottom / left to right)2 columns of data (distributed evenly between both columns - last column might have one name less if the array is of an odd numbered size)--------------------------------------------(GROUP) CHILDREN - GIRLSClaire RosyEvelyn StephanieJessica TaraKylie TracyMargret VanessaOlivia Vivian-------------------------------------------- PROBLEM:When there is a page break for the group, the data still just flows within the columns over the pages as follows:--------------------------------------------(GROUP) CHILDREN - GIRLSClaire RosyEvelyn StephanieJessica Tara<PAGE BREAK>CHILDREN - GIRLS (CONTINUED)Kylie TracyMargret VanessaOlivia Vivian--------------------------------------------SO NOW WE HAVE:Page 1: Column 1: C > JPage 1: Column 2: R > TPage 2: Column 1: K > OPage 2: Column 2: T > V REQUIREMENT:When there is a page break for the group, the COLUMN data should not flow over pages but should first display it alphabetically on the first page (between the two columns) and then continue on the second page alphabetically again.--------------------------------------------(GROUP) CHILDREN - GIRLSClaire KylieEvelyn MargaretJessica Olivia<PAGE BREAK>CHILDREN - GIRLS (CONTINUED)Rosy TracyStephanie VanessaTara Vivian--------------------------------------------SO NOW WE NEED...Page 1: Column 1: C > JPage 1: Column 2: K > OPage 2: Column 1: R > TPage 2: Column 2: T > V CURRENT DATA:Currently to get the data I do the following:Populate an alphabeticalList containing all the girlsUse some processing to split the list into two listscolumn1ListClaireEvelynJessicaKylieMargaretOliviacolumn2ListRosyStephanieTaraTracyVanessaVivianAdd each list to a subreport.column1List assigned to COLUMN1(subreport) in detail bandcolumn2List assigned to COLUMN2(subreport) in detail band QUESTION:Is there ANY way that I can achieve this? Either through Java before I send it to Jasper, or on the iReport side? Maybe even a scriptlet? I need the data to sort alphabetically in a group between the two columns, but if there is going to be a page break it needs to know how much data it can fit in on the page in the group before the page break so that the alphabetical list does not continue to the next page but rather first go to the next column... and then on the next page it should continue as normal. Explaining this sounds confusing so I hope my explanations above are more clear. Link to comment Share on other sites More sharing options...
javalogan Posted July 17, 2015 Author Share Posted July 17, 2015 Using iReport 4.0.1 (jasperreports 4.0.1) JDK 5 Link to comment Share on other sites More sharing options...
Tom C Posted July 18, 2015 Share Posted July 18, 2015 Forget about getting your data in two columns - instead, let JasperReports handle the two column layout. Merging your data into one column, sorting the data in alpha order, then displaying them in report in a two column layout: <jasperReport ...... columnCount="2" ......>[/code] Link to comment Share on other sites More sharing options...
Tom C Posted July 18, 2015 Share Posted July 18, 2015 Link to comment Share on other sites More sharing options...
javalogan Posted July 18, 2015 Author Share Posted July 18, 2015 Thanks for the help Tchen.This works... but then the only problem is that the column data is only distrubted evenly before the page break. After the page break it only fills column 1 (unless it reaches the end of the page again and then starts to fill column 2 from the top).So we get the following (first part of the group starts close to the end of the page - which is why it overflows to the next page)(GROUP) CHILDREN - GIRLSClaire KylieEvelyn MargaretJessica Olivia<PAGE BREAK>CHILDREN - GIRLS (CONTINUED)Rosy Stephanie Tara TracyVanessaVivian--------------------------------------I need the data that follows onto the next page after the page break to also distribute evenly between the columns even if it does not reach the end of the page...Basically, the data needs to distribute evenly between the columns all the time and not only before a page break.Even a normal group which fits on one page (no page break) needs to be distributed evenly instead of first filling the first column till the end of the page and then only starting to fill column2. Link to comment Share on other sites More sharing options...
Solution Tom C Posted July 20, 2015 Solution Share Posted July 20, 2015 The proposed approach only works in a single page. Sorry that my sample report might be misleading since it was based on the specific data provided in your question that happens to have report data evenly divided among two report pages thus a fix page height can be applied to both page layouts. In general, JasperReports engine is not able to help layout the report based on your requirement because:1) report height is defined at design time and cannot be changed during report execution;2) multiple column report layout is based on the available space in the section to determine the column height. It is not capable of auto adjusting the column height to display report content evenly among multiple columns.There's no simple solution to meet your design requirement using JasperReports product. The pixel measurement used in JR report layout, compounded by field overflow stretch, makes it impossible to determine how many characters can fit into a report page in order to evenly layout field content in multiple column with one pass data processing. Link to comment Share on other sites More sharing options...
Tom C Posted July 22, 2015 Share Posted July 22, 2015 Currently JasperReports product is not able to provide the layout as per your design requirement due the complex nature of the process as briefly mentioned in the above posting. I have discussed the issue with our product gurus and confirmed there's no simple configuration using existing JR features to meet this requirement. 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