如果子报表为空,则隐藏文本字段 [英] Hide text field if subreport is empty

查看:144
本文介绍了如果子报表为空,则隐藏文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Jasper 中创建了一个包含四个部分的报告。每个部分都包含一个文本字段作为标题和一个子报表。子报表可以为空。如果它为空,则使用空白时删除行隐藏它。到目前为止这个工作。现在,如果子报表被隐藏,也应该隐藏相应的标题文本字段。

I am creating a report in Jasper with four parts. Each part consists of a text field as the header and a subreport. The subreport can be empty. If it is empty it is hidden using Remove Line When Blank. This works so far. Now, the corresponding header text field should be hidden too if the subreport is hidden.

我尝试过很多东西,但无法提出解决方案。
例如使用打印表达式 new Boolean($ P {otherField} .read()!= -1)。这从未显示过标题。

I have tried many things but couldn't come up with a solution. E.g. using Print When Expression: new Boolean ($P{otherField}.read() != -1). This never showed the header.

我还试图在我的Java程序中隐藏标题但找不到合适的API命令。我猜 getBands()[x] .getChildren()[y] 引导我到正确的标题,但我无法将其隐藏在那里。

As well I tried to hide the header in my Java program but couldn't find an appropriate API command. I guess getBands()[x].getChildren()[y] lead me to the right header but I couldn't hide it there.

还有其他想法吗?

推荐答案

感谢您的帮助。我终于可以通过在标题中的Print When Expression下使用以下表达式来解决它:

Thank you for your help. I finally could solve it by using the following expression under "Print When Expression" in the header:

($P{SUBR}!=null)

其中


$ P {SUBR}

$P{SUBR}

是子报告的表达式。

这篇关于如果子报表为空,则隐藏文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆