您可以在报告生成器 3 中轮换可见的子报告吗? [英] Can you rotate through visible sub reports in report builder 3?

查看:23
本文介绍了您可以在报告生成器 3 中轮换可见的子报告吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一份主报告和几份子报告.本质上,我想轮流显示每个子报告大约 30 秒,然后隐藏第一个,然后显示下一个,然后在所有时间结束后重新启动.

I have one main report with several sub reports. Essentially I want to show each sub report in rotation for about 30 seconds before hiding the first one then showing the next and restarting again after all have had their time up.

谢谢

推荐答案

我认为"你可以做到这一点,但有一些注意事项.

I 'think' you can do this, but there are some caveats.

您需要设置一个数据库表来存储当前循环位置,如果您有多个这样的报告,您可以将其键入报告名称.

You will need to setup a database table to store the current loop position, if you have several of these reports you could key it on report name for example.

(注意这些名字是针对主报表的,与子报表无关)

(note these names are for the main report, nothing to do with the subreports)

ReportName     LoopPosition LoopMax
MyMainReportA        0         3
AnotherReport        7        10 

将数据集(我们称之为 dsLoop)添加到您的主报告中,以更新此值并返回类似的值.(未经测试)

Add a dataset (lets call it dsLoop) to your main report that updates this value and returns it with something like. (Untested)

DECLARE @LoopPosition int
SELECT @LoopPosition =  CASE LoopPosition WHEN LoopMax THEN 1 ELSE LoopPosition + 1 END
    FROM myReportLoopTable 
    WHERE ReportName = 'MyMainReportA'

    UPDATE myReportLoopTable Set LoopPosition = @LoopPosition WHERE ReportName = 'MyMainReportA'

SELECT @LoopPosition as LPos

此代码只是将 LoopPosition 加 1 或在达到最大值时将其重置为 1.然后它返回这个值.

This code simply adds 1 to the LoopPosition or resets it to 1 if we've hit the maximum value. It then returns this value.

现在将参数 pLoopPos 添加到您的主报告(这可以是一个隐藏参数)并将其设置为我们新的 dsLoop 数据集的默认值.

Now add a parameter pLoopPos to your main report (this can be a hidden parameter) and set it default value to our new dsLoop dataset.

现在将每个子报表的隐藏属性更改为仅在 Parameters!pLoopPos.Value = x 时显示子报表,其中 x 是子报表的顺序.

Now change the hidden property of each subreport to only show the subreport when Parameters!pLoopPos.Value = x where x is the order of the subreport.

现在,当报告运行时,它将更新循环位置并获得新值.第一个子报告将显示为 pLoopPos 为 1 .当您的报告刷新(通过 AutoRfresh 属性)时,将重新评估 dsLoop 数据集,这将运行代码以更新值.pLoopPos 值将增加并显示下一个子报表.

Now, when the report runs it will update the loop position and get the new value. The first subreport will show as the pLoopPos will be 1 . When your report refreshes (via the AutoRfresh property) the dsLoop dataset will be reevaluated which will run the code to update the value. The pLoopPos value will increase and the next subreport will be displayed.

您可能必须强制始终刷新参数(从参数属性).

You may have to force the parameter to always be refreshed (from the parameter properties).

请注意这是未经试验和未经测试的.这只是我的想法,所以我建议先写一份简单的测试报告,然后再花太多时间尝试实施它.

PLEASE NOTE THIS IS UNTRIED AND UNTESTED. This is just off the top of my head so I suggest a simple test report before spending too much time trying to implement it.

更新:2018-04-10 根据您的后续问题,使用该参数似乎不起作用,因为它不会刷新.但是,您可以直接使用 dsLoop 返回的值.要进行更改,只需换出

UPDATE: 2018-04-10 Following on from your followup question, it looks like using the parameter wont work as it does not get refreshed. However you can use the value the dsLoop returns directly. To make the change, simply swap out

Parameters!pLoopPos.Value with =First(Fields!LPos.Value, "dsLoop")

注意:我稍微修改了 dsLoop 查询,为最终结果命名(LPos).

Note: I modified the dsLoop query slightly to give the final result a name (LPos).

您现在应该能够删除不再使用的参数.

You should now be able to delete the parameter as its no longer used.

这篇关于您可以在报告生成器 3 中轮换可见的子报告吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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