问题描述
positionType="Float"
会将自身拉下.但是,如果上述组件缩小/未显示,则不会向上移动.
positionType="Float"
on a component pulls itself down if the above component stretches. But doesn't move up if the above component shrinks/not displayed.
下面是使用的版本:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>
<version>6.0.0</version>
</dependency>
将重现上述问题的代码:
Code that will reproduce the above issue:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 -->
<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="sample" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="acaa0a15-dc0f-462c-8d16-14f0b7325696">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<summary>
<band height="500" splitType="Prevent">
<staticText>
<reportElement positionType="Float" x="0" y="19" width="381" height="41" isRemoveLineWhenBlank="true" uuid="9547d877-993c-4bb4-becc-cf70a0cc1bc2">
<printWhenExpression><![CDATA[false]]></printWhenExpression>
</reportElement>
<text><![CDATA[Text11111111111111111111]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="0" y="150" width="381" height="41" isRemoveLineWhenBlank="true" uuid="9e7dbe2e-2fed-41c8-82ce-c0c6886c8eda">
<printWhenExpression><![CDATA[true]]></printWhenExpression>
</reportElement>
<text><![CDATA[Text22222222222222222222]]></text>
</staticText>
</band>
</summary>
</jasperReport>
以上代码仅显示第二个静态文本组件,而不显示第一个.因为第一个中的printWhenExpression
是false
.
Above code displays only second static text component but not first. Because the printWhenExpression
in the first is false
.
现在,我希望第二个组件代替第一个组件显示,但是不希望显示.结果,我在那里得到了空间.
Now I want the second component to display in place of first, but it doesn't. As a result I'm getting space there.
如何删除空白?
推荐答案
来自 JasperReports文档强调我的
第二个reportElement不会向上移动到第一个reportElement所在的位置,因为它保留了它们之间的距离.下图所示的距离:
The second reportElement will not move up to where the first reportElement is because it conserve the distance between them. The distance illustrated in image below:
如果您希望reportElement 2取代reportElement 1,那么您的解决方案是删除此空间!
Your solution is remove this space!, if you like reportElement 2 to take reportElement 1 place
删除该空间,但如果第二个reportElement存在,则保留其位置.增加reportElement 1的高度.
Remove the space but keep position of second reportElement if first is present. Increase height of reportElement 1.
通过将reportElement 2向上移动来删除空间,如果它是textField(动态文本),则在reportElement 1溢出时,可以在reportElement 1上使用isStretchWithOverflow="true"
来将reportElement 2向下推.
Remove the space by moving reportElement 2 up, if it is a textField (dynamic text) you can use isStretchWithOverflow="true"
on reportElement 1 to push reportElement 2 down if reportElement 1 is overflowing.
这篇关于当上面的组件未在jasper中显示时,如何使用positionType来拉起组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!