Steve.Sargent Posted June 26, 2017 Share Posted June 26, 2017 [/code]I am coming up with a problem, where a detail band that does not fit in the remaining real-estate of the given column, is having partial duplication of details on the next column. I believe this might have to do with the subreport, which is the last item in the details band. The following is a sample of the code that is being used, along with the subreport evaluated in the details band (it is derived, since I cannot put in actual jrxml files, due to company policy)(I apologize for the terrible formatting. I was unable to get the code block to accept the full xml in the brackets)<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 --><!-- 2017-06-26T12:03:30 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" columnCount="2" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" scriptletClass="path.to.my.scriptlet" uuid="af53d807-7975-4ff7-bfc5-e438944aa795"><property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/><queryString><![CDATA[]]></queryString><field name="Name" class="java.lang.String"/><field name="Address" class="java.lang.String"/><field name="City" class="java.lang.String"/><field name="State" class="java.lang.String"/><field name="Zip" class="java.lang.String"/><field name="AdditionalLocations" class="java.util.List"/><sortField name="City"/><group name="City" isReprintHeaderOnEachPage="true" minHeightToStartNewPage="450"><groupExpression><![CDATA[$F{City}]]></groupExpression><groupHeader><band height="20" splitType="Prevent"><property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <frame><reportElement positionType="Float" x="0" y="0" width="555" height="20" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" printWhenGroupChanges="City" uuid="bc45f51d-5242-4c8f-b2ca-28ff30443753"/><textField isStretchWithOverflow="true"><reportElement positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="0" y="0" width="175" height="20" isPrintWhenDetailOverflows="true" printWhenGroupChanges="City" forecolor="#FFFFFF" backcolor="#2992FC" uuid="3248c7d3-7975-4c51-acc2-d9681988cb89"><property name="com.jaspersoft.studio.unit.width" value="pixel"/></reportElement><textElement textAlignment="Center" verticalAlignment="Middle"><font size="15"/></textElement><textFieldExpression><![CDATA[$F{City} == null? " " : $F{City}.toUpperCase()]]></textFieldExpression></textField></frame></band></groupHeader></group><detail><band height="426" splitType="Stretch"><property name="com.jaspersoft.studio.unit.height" value="pixel"/><property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/><textField isStretchWithOverflow="true"><reportElement positionType="Float" x="0" y="10" width="100" height="30" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="853a1b0d-a49e-45c4-8183-83cfd69bf5af"><printWhenExpression><![CDATA[($F{Name} == null ? Boolean.FALSE : Boolean.TRUE)]]></printWhenExpression></reportElement><textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression></textField><textField isStretchWithOverflow="true" isBlankWhenNull="true"><reportElement positionType="Float" x="0" y="50" width="100" height="30" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="46697c6d-1c2f-422b-9170-6b2f36ce13ba"><printWhenExpression><![CDATA[($F{Address} == null ? Boolean.FALSE : Boolean.TRUE)]]></printWhenExpression></reportElement><textFieldExpression><![CDATA[$F{Address}]]></textFieldExpression></textField><textField isStretchWithOverflow="true" isBlankWhenNull="true"><reportElement positionType="Float" x="0" y="90" width="100" height="30" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="31730cd5-0b17-452e-8a22-d16ea2061605"><printWhenExpression><![CDATA[($F{City} == null ? Boolean.FALSE : Boolean.TRUE)]]></printWhenExpression></reportElement><textFieldExpression><![CDATA[$F{City}]]></textFieldExpression></textField><textField isStretchWithOverflow="true" isBlankWhenNull="true"><reportElement positionType="Float" x="0" y="120" width="100" height="30" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="b4a4c671-dc63-41b4-b080-9ad5b750bb58"><printWhenExpression><![CDATA[($F{State} == null ? Boolean.FALSE : Boolean.TRUE)]]></printWhenExpression></reportElement><textFieldExpression><![CDATA[$F{State}]]></textFieldExpression></textField><textField isStretchWithOverflow="true" isBlankWhenNull="true"><reportElement positionType="Float" x="0" y="160" width="100" height="30" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="8f8bec7c-3d4a-466b-8b02-2bb82e61904d"><printWhenExpression><![CDATA[($F{Zip} == null ? Boolean.FALSE : Boolean.TRUE)]]></printWhenExpression></reportElement><textFieldExpression><![CDATA[$F{Zip}]]></textFieldExpression></textField><textField isStretchWithOverflow="true" isBlankWhenNull="true"><reportElement positionType="Float" x="0" y="198" width="100" height="30" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="8f8bec7c-3d4a-466b-8b02-2bb82e61904d"><printWhenExpression><![CDATA[iF($F{AdditionalLocations}.isEmpty(),FALSE( ),TRUE( ))]]></printWhenExpression></reportElement><textFieldExpression><![CDATA["Additional Locations"]]></textFieldExpression></textField> <subreport><reportElement positionType="Float" x="0" y="220" width="100" height="110" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="4887e0c1-3da2-4350-9454-4a3e33c0fe71"><printWhenExpression><![CDATA[iF($F{AdditionalLocations}.isEmpty(),FALSE( ),TRUE( ))]]></printWhenExpression></reportElement><dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{AdditionalLocations})]]></dataSourceExpression><subreportExpression><![CDATA["Blank_A4_1.jasper"]]></subreportExpression></subreport></band></detail></jasperReport> Subreport file:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 --><!-- 2017-06-26T13:27:22 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9b8a1d93-2ee6-4d29-b9ec-7c56a3917729"><queryString><![CDATA[]]></queryString><field name="Address" class="java.lang.String"/><field name="City" class="java.lang.String"/><field name="State" class="java.lang.String"/><field name="Zip" class="java.lang.String"/><detail><band height="168" splitType="Stretch"><textField isStretchWithOverflow="true" isBlankWhenNull="true"><reportElement positionType="Float" x="0" y="10" width="100" height="30" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="3d74e624-6b6f-40e9-87d2-ddb5022668b2"><property name="com.jaspersoft.studio.unit.width" value="pixel"/><printWhenExpression><![CDATA[($F{Address}.equals(null)? Boolean.FALSE : Boolean.TRUE)]]></printWhenExpression></reportElement><textFieldExpression><![CDATA[$F{Address}]]></textFieldExpression></textField><textField isStretchWithOverflow="true" isBlankWhenNull="true"><reportElement positionType="Float" x="0" y="50" width="100" height="30" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="5df31fa3-38ee-44a4-8931-e8eef45fb7a6"><property name="com.jaspersoft.studio.unit.width" value="pixel"/><printWhenExpression><![CDATA[($F{City}.equals(null)? Boolean.FALSE : Boolean.TRUE)]]></printWhenExpression></reportElement><textFieldExpression><![CDATA[$F{City}]]></textFieldExpression></textField><textField isStretchWithOverflow="true" isBlankWhenNull="true"><reportElement positionType="Float" x="0" y="89" width="100" height="30" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="964a282f-54c7-44a3-954d-27d1c70d3d0c"><property name="com.jaspersoft.studio.unit.width" value="pixel"/><printWhenExpression><![CDATA[($F{State}.equals(null)? Boolean.FALSE : Boolean.TRUE)]]></printWhenExpression></reportElement><textFieldExpression><![CDATA[$F{State}]]></textFieldExpression></textField><textField isStretchWithOverflow="true" isBlankWhenNull="true"><reportElement positionType="Float" x="0" y="130" width="100" height="30" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="e1349222-d945-4dec-8454-e2d6e3fb6a2a"><property name="com.jaspersoft.studio.unit.width" value="pixel"/><printWhenExpression><![CDATA[($F{Zip}.equals(null)? Boolean.FALSE : Boolean.TRUE)]]></printWhenExpression></reportElement><textFieldExpression><![CDATA[$F{Zip}]]></textFieldExpression></textField></band></detail></jasperReport> The two files above are creating documents similar to the following table: (grouping removed)Name1Name1Address1Address1City1City1State1State1Zip1Zip1Additional Locations 1Additional Locations 1 AL-Address1 AL-City2 AL-City1 AL-State2 AL-State1 AL-Zip2 AL-State1 AL-Address2 What I am looking for is no repeat of data (for now. Am also looking for some functionality to reproduce name on each column, but that is for another post), but am not sure what I've done (or not done) that is causing the duplications. Any help in this would be greatly appreciated. Link to comment Share on other sites More sharing options...
dohungnd94 Posted June 27, 2017 Share Posted June 27, 2017 You must check carefully your SQL query, if you do not want the duplications happen, you can select distinct. Link to comment Share on other sites More sharing options...
dohungnd94 Posted June 27, 2017 Share Posted June 27, 2017 In my opinion, I think your problem about your SQL query. U can display your report based on your query Link to comment Share on other sites More sharing options...
Steve.Sargent Posted June 27, 2017 Author Share Posted June 27, 2017 the data is not duplicated. The contents shown represent a single record, which has a list of additional locations within it.. Link to comment Share on other sites More sharing options...
dohungnd94 Posted June 28, 2017 Share Posted June 28, 2017 What I mean when I said that u should check your SQL query because I saw u used 2 column in your page, but your detail still duplicated in two column. You can use " select distinct " in your SQL query, or use " Order by City" , may be it can fix your problem. Link to comment Share on other sites More sharing options...
Steve.Sargent Posted June 29, 2017 Author Share Posted June 29, 2017 we are not using a sql query. Data is being sent in directly from a JRBeanDataSource (might have the name wrong, but essentially being sent in a list of beans) 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