将主要参数传递给JasperStudio中的子数据集 [英] Passing main parameter to sub-datasets in JasperStudio

查看:380
本文介绍了将主要参数传递给JasperStudio中的子数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JasperStudio 5.5中创建了一个报告,该报告在main中定义了许多参数,并且需要使用这些参数的许多子数据集(用表定义)。

i'm created a report with JasperStudio 5.5 that have many parameter defined in the main and a lot of sub-dataset (defined with tables) that required this parameters.

情况:

/ main /参数:myPar

/main/Parameters: myPar

/ main / mySubDataSet1 /

/ main / mySubDataSet2 /

...

/ main / mySubDataSetN /

/main/mySubDataSet1/
/main/mySubDataSet2/
...
/main/mySubDataSetN/

子数据集需要在她的查询中使用此参数:select * from Tab t其中t.attr = $ P!{myPar}

The sub-dataset need to use this parameter in her query: select * from Tab t where t.attr = $P!{myPar}

所以,我的问题是子数据集可以在这个主要参数中访问,我尝试编译的所有时间,程序发送给我参数未找到:myPar。

So, my problem is that the sub-dataset can't access at this main paramenter, all the time that i try compiled, the program send me "Parameter not found : myPar".

如何在子数据集中使用myPar?

How i can do for use myPar in the sub-dataset?

ps:我读了这个帖子< a href =http://community.jaspersoft.com/questions/541915/pass-main-dataset-parameter-subdataset-query =nofollow>将主数据集参数传递给子数据集查询(基于iReport)但没有成功...

p.s.: i read this thread Pass main dataset parameter to subdataset query (based on iReport) but without success...

推荐答案

那么,您需要使用实际使用它们的值填充subDataset参数。在这种情况下,列出subDataset项目的表需要声明必要的参数并将报告级数据集参数的值分配给它们。

Well, you need to fill subDataset parameters with values where you actually make use of them. In this case the table which lists items from your subDataset needs to declare the necessary parameters and assign the values of the report-level dataset parameters to them.

在jrxml中它听起来:

In jrxml it sounds:

<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
    <datasetRun subDataset="mySubDataSet1" uuid="bbe7937c-a8f1-4838-811a-3f11ec1f8e35">
        <datasetParameter name="myPar">
            <datasetParameterExpression><![CDATA[$P{myPar}]]></datasetParameterExpression>
        </datasetParameter>
        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
    </datasetRun>
    ...
</jr:table>

这篇关于将主要参数传递给JasperStudio中的子数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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