如何将值从表的数据源返回到 iReport 中的主报表? [英] How to return value from table's DataSource to main report in iReport?

查看:14
本文介绍了如何将值从表的数据源返回到 iReport 中的主报表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 iReport 中有一个表,它自然有它的数据集,我有一个变量,它在表的数据集中定义和初始化,返回一个我想要的值(肯定在表的范围内,而不是在表的范围内)在包含表格的主报告中使用.

I have a table in my iReport which naturally has its dataset and I have a variable, that is defined and initialized in the table's dataset return a value (which definitely does within scope of table, not outside it) which I want to use in my main report which holds the table.

我怎样才能做到这一点或任何替代方案?

How can I do that or any alternatives?

推荐答案

使用 subDataset 从组件返回值的正确方法(jasper report v.5/v.6)是使用变量,在主报告和 subDataset<中定义变量/代码>.

The correct way (jasper report v.5/v.6) to return values from a component using subDataset is to use variables, define variables in both main report and in subDataset.

示例(将表的记录数返回到主报表)

Example (return record count of table to main report)

  1. 在主报告中定义一个变量

  1. In main report define a variable

<variable name="TABLE_COUNT" class="java.lang.Integer" resetType="None">
   <initialValueExpression><![CDATA[0]]></initialValueExpression>
</variable>

  • subdataset 中定义一个变量(例如,将使用内置变量 $V{REPORT_COUNT}).

  • In subdataset define a variable (in example a build in variable will be used $V{REPORT_COUNT}).

    datasetRun中指明哪个subDataset变量(fromVariable)应该返回哪个主报表变量(toVariable)

    In datasetRun indicate which subDataset variable (fromVariable) should be return to which main report variable (toVariable)

    <datasetRun subDataset="tableData" uuid="fa5df3de-f4c5-4bfc-8274-bd064e8b81e6">
       <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
       <returnValue fromVariable="REPORT_COUNT" toVariable="TABLE_COUNT"/>
    </datasetRun>
    

  • TABLE_COUNT 变量随后可以在主报告中使用,只要记住设置正确的 evaluationTime

    The TABLE_COUNT variable can then be used in the main report, just remember to set correct evaluationTime

    显示值(在主报告中)

    <textField evaluationTime="Report">
        <reportElement x="0" y="0" width="100" height="20" uuid="d67ddb3e-b0cc-4fae-9e05-f40eb0f7e059"/>
        <textFieldExpression><![CDATA[$V{TABLE_COUNT}]]></textFieldExpression>
    </textField>
    

    这篇关于如何将值从表的数据源返回到 iReport 中的主报表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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