JasperReports: nested records do not work with positionType = 'Float'

In this example, the overlap overlaps - what am I doing wrong? The second should β€œfloat” below the first, while its β€œy” attribute is ignored, but it is not.

Thanks!

<?xml version="1.0" encoding="UTF-8"?> <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="report name" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> <defaultValueExpression><![CDATA["C:\\reportFolder\\"]]></defaultValueExpression> </parameter> <background> <band/> </background> <detail> <band height="200"> <subreport> <reportElement positionType="FixRelativeToTop" x="19" y="0" width="200" height="50"/> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "report1.jasper"]]></subreportExpression> </subreport> <subreport> <reportElement positionType="Float" mode="Transparent" x="19" y="20" width="200" height="50" backcolor="#FFFF66"/> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "report1.jasper"]]></subreportExpression> </subreport> </band> </detail> </jasperReport> 
+4
jasper-reports
source share
2 answers

I got an answer! (I am the one who asked, in another IP) According to the documentation, a floating element will ignore its y-attribute. I took it literally, tried arbitrary values ​​for y and saw that every time an element was placed at the specified position.

But no, you need to set y to position the element directly below the previous one, in accordance with the specified y element and height , although its actual height can be stretched when filling with data. In my code example, the second subreport should have y = "50".

In addition, I see that the declared height of the element is taken as the minimum height. If the actual sub-register is shorter than the height, the closing element will not shrink, so it would be nice to set the minimum expected height for elements that could stretch.

+12
source share

You are right, but you need more. You need to remove fields from subscriptions.

  • From the menu β†’ Format β†’ Delete report fields from the menu

  • Format β†’ Page Format β†’ Make Fields 0

+2
source share

All Articles