如何在JasperReports中使用条件TextField? [英] How can I use a conditional TextField in JasperReports?

查看:516
本文介绍了如何在JasperReports中使用条件TextField?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有一对TextFields取决于值。并且应根据空白区域调整y值。

I would like to have a pair of TextFields depending on a value. And the "y"-value should be adjusted depending on the empty space.

当值0时我想隐藏TextField。

When the value is "0" I would like to hide the TextField.

即如果参数 red staticText textField $ c>等于0并将蓝色值向上移动,在下面的jrxml代码中:

I.e. I would like to hide the staticText and the textField if the parameter red is equal to "0" and have the blue values moved up, in the jrxml-code below:

  <staticText>
    <reportElement x="100" y="30" width="100" height="30"/>
    <text><![CDATA[Red items:]]></text>
  </staticText>
  <textField>
    <reportElement x="200" y="30" width="40" height="30"/>
    <textFieldExpression>
      <![CDATA[$P{red}]]>
    </textFieldExpression>
  </textField>

  <staticText>
    <reportElement x="100" y="60" width="100" height="30"/>
    <text><![CDATA[Blue items:]]></text>
  </staticText>
  <textField>
    <reportElement x="200" y="60" width="40" height="30"/>
    <textFieldExpression>
      <![CDATA[$P{blue}]]>
    </textFieldExpression>
  </textField>

输出示例:

//if blue = 3 and red = 2    if blue = 3 and red = 0    if blue = 0 and red = 2
    Red items: 2               Blue items: 3              Red items: 2
    Blue items: 3    

这些TextFields将放在我的报告末尾。我该怎么做?

These TextFields will be placed at the end of my report. How can I do this?

推荐答案

<reportElement ...>
    <printWhenExpression><![CDATA[$P{red} == 0]]></printWhenExpression>
</reportElement>

您可以使用iReport通过愉快的用户界面对其进行修改。

You can use iReport to modify this with a pleasant UI.

这篇关于如何在JasperReports中使用条件TextField?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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