JasperReports:隐藏帧A中的帧B,如果帧B中的字段为空或为空 [英] JasperReports: Hide frame B within frame A, if one the fields inside frame B is null or is empty

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

问题描述

我在jasper报告中遇到有关设计文档模板的问题。这就像一份简历。

I am having a problem in jasper reports regarding designing a document template. It's like a resume.

我有这个文件:

年龄[静态文本] | [某些字段A]

Age [static text] | [some field A]

性别[静态文本] | [某些字段B]

Gender [static text] | [some field B]

位置[静态文本] | [某些字段C]

Location [static text] | [some field C]

我的jasper报告的当前结构如下:

The current structure of my jasper reports is this:

我有这个框架A ,有垂直布局。
模板中的每一行(年龄,性别,位置)对应于我创建第1,2和3帧的帧。

I have this frame A, which has a vertical layout. Every row in the template (age, gender, location) corresponds to the frame I've created frames 1, 2 and 3.

说,第1帧具有水平布局,其中'Age [静态文本]'和'[some field A]'作为其内容。适用于第2帧和第3帧。

Say, frame 1 has horizontal layout with 'Age [static text]' and '[some field A]' as its contents. The applies to frames 2 and 3.

第1帧的位置类型相对于顶部是固定的,而第2帧和第3帧是浮动的。

Frame 1 has a position type of fix relative to top, while frames 2 and 3 are in float.

如果[某个字段] B为空或空,我希望隐藏行性别并向上移动。我该怎么做?

I want the row gender be hidden and be moved upwards if [some field] B is null or empty. How can I do that?

我尝试过删除行空白但它只适用于包含多个字段的帧内。基本上,我希望隐藏第1帧,如果[某个字段A]为空或空,则将帧2和3向上移动。

I've tried working on Remove Line When Blank but it only works inside a frame which has several fields in it. Basically, I want frame 1 to be hidden and have frames 2 and 3 be moved upwards if [some field A] is null or empty.

我希望最快的响应。

推荐答案

为了达到理想的结果集:

To achieve you desired result set:


  1. 内的 reportElement 上的positionType =Float框架(需要根据其他元素移动

  1. positionType="Float" on the reportElement inside the frame (it needs to move on the basis of the other elements.

isRemoveLineWhenBlank =true,如果根据 printWhenExpression

printWhenExpression es。<$中包括检查所有框架内的字段c $ c> new Boolean($ F {field1} == null || $ F {field2} == null || $ F {field3} == null)

Include the check for all the fields inside the frame in the printWhenExpression es. new Boolean($F{field1}==null || $F{field2}==null || $F{field3}==null)

示例

<frame>
   <reportElement positionType="Float" x="13" y="12" width="287" height="35" isRemoveLineWhenBlank="true" uuid="ee6707a4-bcb4-402b-95c0-6f4613747d2f">
      <printWhenExpression><![CDATA[new Boolean($F{field1}==null || $F{field2}==null || $F{field3}==null)]]></printWhenExpression>
       .. your textFields ...
   </reportElement>
</frame> 

注意:兼容jasper report 3和jdk 1.4我用过新的布尔值(...)这在jasper报告5,6

NOTE: for compatibility with jasper report 3 and jdk 1.4 I have used new Boolean(...) this is not necessary in jasper report 5,6

这篇关于JasperReports:隐藏帧A中的帧B,如果帧B中的字段为空或为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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