Jump to content

Recommended Posts

Posted

Hello,

I encountered with the problem by controlling subreport detail band height. I am trying to make Master's columns and subreport detail band the same height. If there is enough data in subreport, then everything is fine. However, I am failing if Master's column is stretching and subreport has small amount of data. You can see in the picture below, that subreport column borders (red columns) is not the same height as Masters (green columns). Is it posible to stretch somehow subreports columns?

Capture(28).PNG.95484ebccec979e22cae33dbfd3c1e26.PNG


Master code:

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.0.4.final using JasperReports Library version 6.0.4  --><!-- 2015-04-26T21:49:07 --><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="testas" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="46b128e3-c44b-4cf9-9632-d836edd8247f"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/> <queryString language="SQL">  <![CDATA[select   0 region_id,   'Middle East and Africa' region_namefrom dualunionselect   1 region_id,   'Americas' region_namefrom dual]]> </queryString> <field name="REGION_ID" class="java.math.BigDecimal"/> <field name="REGION_NAME" class="java.lang.String"/> <group name="REGION_NAME">  <groupExpression><![CDATA[$F{REGION_NAME}]]></groupExpression> </group> <background>  <band splitType="Stretch"/> </background> <detail>  <band height="29" splitType="Stretch">   <textField>    <reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="0" y="13" width="130" height="15" backcolor="#CFFCDC" uuid="79c90aca-72e2-4f58-bd19-b5031a500445">     <property name="local_mesure_unitheight" value="pixel"/>     <property name="com.jaspersoft.studio.unit.height" value="px"/>    </reportElement>    <box>     <topPen lineWidth="1.0"/>     <leftPen lineWidth="1.0"/>     <bottomPen lineWidth="1.0"/>     <rightPen lineWidth="1.0"/>    </box>    <textFieldExpression><![CDATA[$F{REGION_ID}]]></textFieldExpression>   </textField>   <textField isStretchWithOverflow="true">    <reportElement positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="130" y="13" width="70" height="15" backcolor="#CFFCDC" uuid="7c53fb2b-599f-4035-b84c-4cbb2a8c8f81">     <property name="local_mesure_unitheight" value="pixel"/>     <property name="com.jaspersoft.studio.unit.height" value="px"/>    </reportElement>    <box>     <topPen lineWidth="1.0"/>     <leftPen lineWidth="1.0"/>     <bottomPen lineWidth="1.0"/>     <rightPen lineWidth="1.0"/>    </box>    <textFieldExpression><![CDATA[$F{REGION_NAME}]]></textFieldExpression>   </textField>   <subreport runToBottom="false">    <reportElement positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="200" y="13" width="220" height="15" backcolor="#FFA4A1" uuid="ae15b177-2b3f-496a-9e17-688d484902f3">     <property name="local_mesure_unitheight" value="pixel"/>     <property name="com.jaspersoft.studio.unit.height" value="px"/>     <property name="local_mesure_unitwidth" value="pixel"/>     <property name="com.jaspersoft.studio.unit.width" value="px"/>    </reportElement>    <subreportParameter name="reg_id">     <subreportParameterExpression><![CDATA[$F{REGION_ID}]]></subreportParameterExpression>    </subreportParameter>    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>    <subreportExpression><![CDATA["testai/subreport.jasper"]]></subreportExpression>   </subreport>  </band> </detail></jasperReport>[/code]

Subreport code:

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.0.4.final using JasperReports Library version 6.0.4  --><!-- 2015-04-26T21:43:56 --><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="subreport" pageWidth="220" pageHeight="802" columnWidth="220" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="f2bc8cec-8dfb-4633-b132-b4888fe2c731"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/> <property name="com.jaspersoft.studio.unit." value="pixel"/> <parameter name="reg_id" class="java.math.BigDecimal"/> <queryString language="SQL">  <![CDATA[select country_id, country_namefrom  (select       1 region_id,       'AR' country_id,      'Argentina' country_name  from dual  union  select       1 region_id,       'USA' country_id,      'United States of America' country_name  from dual  union  select       0 region_id,       'ZW' country_id,      'Zimbabwe' country_name  from dual) t where t.region_id = $P{reg_id}]]> </queryString> <field name="COUNTRY_ID" class="java.lang.String"/> <field name="COUNTRY_NAME" class="java.lang.String"/> <detail>  <band height="15" splitType="Stretch">   <property name="local_mesure_unitheight" value="pixel"/>   <property name="com.jaspersoft.studio.unit.height" value="px"/>   <textField isStretchWithOverflow="true">    <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="138" height="15" uuid="a067ea10-f740-4056-a445-f8dfa497061c">     <property name="local_mesure_unitheight" value="pixel"/>     <property name="com.jaspersoft.studio.unit.height" value="px"/>    </reportElement>    <box>     <topPen lineWidth="1.0"/>     <leftPen lineWidth="1.0"/>     <bottomPen lineWidth="1.0"/>     <rightPen lineWidth="1.0"/>    </box>    <textFieldExpression><![CDATA[$F{COUNTRY_ID}]]></textFieldExpression>   </textField>   <textField isStretchWithOverflow="true">    <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="138" y="0" width="82" height="15" uuid="680b2027-75af-42eb-88ac-3115f5d6a33c">     <property name="local_mesure_unitheight" value="pixel"/>     <property name="com.jaspersoft.studio.unit.height" value="px"/>     <property name="local_mesure_unitwidth" value="pixel"/>     <property name="com.jaspersoft.studio.unit.width" value="px"/>    </reportElement>    <box>     <topPen lineWidth="1.0"/>     <leftPen lineWidth="1.0"/>     <bottomPen lineWidth="1.0"/>     <rightPen lineWidth="1.0"/>    </box>    <textFieldExpression><![CDATA[$F{COUNTRY_NAME}]]></textFieldExpression>   </textField>  </band> </detail></jasperReport>[/code]

 

P. S. How do you format your code to look good?

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

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