如何根据内容隐藏表格列? [英] How do I hide a table column based on its content?

查看:102
本文介绍了如何根据内容隐藏表格列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一份包含表格的报告。我想根据支持表的查询的结果集隐藏该表的列。例如,以下是其中一列的XML:

I have a report which contains a table. I would like to hide the columns of that table based on the result set of the query that backs the table. As an example, here is the XML for one of the columns:

      <jr:column width="80">
        <printWhenExpression>$F{Total1_header} != null</printWhenExpression>
        <jr:columnHeader height="30" rowSpan="1">
          <textField isStretchWithOverflow="true" isBlankWhenNull="true">
            <reportElement x="0" y="0" width="80" height="30" style="table_CH"/>
            <textElement textAlignment="Center" verticalAlignment="Middle"/>
            <textFieldExpression>$F{Total1_header}</textFieldExpression>
          </textField>
        </jr:columnHeader>
        <jr:detailCell style="table_TD" height="20" rowSpan="1">
          <textField isStretchWithOverflow="true" isBlankWhenNull="true">
            <reportElement x="0" y="0" width="80" height="20"/>
            <textElement textAlignment="Center" verticalAlignment="Middle"/>
            <textFieldExpression>$F{Total1}</textFieldExpression>
          </textField>
        </jr:detailCell>
      </jr:column>

出于某种原因,我的报告抱怨 printWhenExpression 。它声称 $ F {Total1_header} 不存在。但它并没有抱怨 textFieldExpression $ F {Total1_header} 的实例。

For some reason, my report is complaining about the printWhenExpression. It claims that $F{Total1_header} does not exist. It does not complain however about the instance of $F{Total1_header} in the textFieldExpression.

我无法弄清楚为什么该字段可用于 textFieldExpression ,而不是 printWhenExpression

I can't figure out why the field is avaiable for the textFieldExpression, but not the printWhenExpression.

推荐答案

对于未来的读者

你应该使用这个

< printWhenExpression> ;<![CDATA [$ F {Total1_header}!= null]]>< / printWhenExpression>

而不是

< printWhenExpression> $ F {Total1_header}!= null< / printWhenExpression>

这篇关于如何根据内容隐藏表格列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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