2004 IR Help Posted August 20, 2006 Share Posted August 20, 2006 By: Phillip Baird - phillipb Can you page break based on a field value? 2005-02-22 22:07 I would like to force a page break after any detail line which has a field that contains a specific value. e.g. page break after a field contains the value "c". a b c {page-break} a b... The only way I think this can be done is by creating a group with setStartNewPage(true) and setting the group's expression to a variable that is only incremented when the field contains the required value. This kind of works but the page break is before rather than after the detail line containing the field value. At the moment I'm getting... a b {page-break} c a b... Anyone have any suggestions on how I can achieve this? thanks /PhillipB Link to comment Share on other sites More sharing options...
grzewal Posted October 11, 2006 Share Posted October 11, 2006 Here's my idea: You can try to create a group with group expression set to $V{PAGE_COUNT} and a start on new page property set to true, header set to for example 1px and footer to 0px, printWhenExpression for group header set to new Boolean($F{someField}.equals("some value")), This way every time the field called someField will contain a value equal "same value" the group header will be rendered and a page break will be introduced. HTH,Grzewal Link to comment Share on other sites More sharing options...
jjcapa Posted November 17, 2016 Share Posted November 17, 2016 I think there are various different approaches to this issue. The most intuitive one is setting the group's property "Start on a new page" to true and defining the "Print when expression" with some condition you want to be true for printing the group. Grzewal expose this approach in his answer. Unfortunally, it didn't work for me.The way I managed to make it working is this one:I defined a group and inside it, a break element. Instead of setting the Group's "Print when expression" and "Start on a new page" properties, I left them as default and I set the Break's "Print when expression" property with the conditions I wanted. In my case, printing a new page break depending on the value of a specific field. I also wanted to print a page break at the end of the detail, so this one could keep isolated from the others pages.<group name="group_name"> <groupExpression><![CDATA[$F{content}]]></groupExpression> <groupHeader> <band height="1"> <break> <reportElement x="0" y="0" width="100" height="1" uuid="b302b3ee-53f3-4926-8049-f75a5d1eae58"> <printWhenExpression> <![CDATA[$F{newPage} == true && $V{PAGE_NUMBER} != 1]]> </printWhenExpression> </reportElement> </break> </band> </groupHeader> <groupFooter> <band height="1"> <break> <reportElement x="0" y="0" width="100" height="1" uuid="aabaf6fd-61c1-484c-8125-e44a69ec6975"> <printWhenExpression> <![CDATA[$F{newPage} == true]]> </printWhenExpression> </reportElement> </break> </band> </groupFooter></group>[/code] 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