从 Silverlight ReportViewer 应用程序设置 Telerik 报表参数
我有一个 Silverlight 应用程序,其中包含 Telerik ReportViewer。我想选择一个报告和代码中的参数值,并将这些信息传递给报告查看器。有谁知道该怎么做?我所能找到的就是将 Report 属性设置为报告的名称。
I have a Silverlight application that has a Telerik ReportViewer contained in it. I want to select a report and the parameter values in code and pass this information to the report viewer. Does anyone know how to do this? All I can find is setting the Report property to the name of the report.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您为 ReportViewer 的 RenderBegin 事件定义处理程序,您将收到一个 RenderBeginEventArgs 参数,其中包含一个名为 ParameterValues 的空 NameValueDictionary 属性。
您可以将 {name, value} 对添加到此集合中,它们似乎在报告的参数集合中完成。
例如,我有两个名为“InputElementID”和“ReportPeriod”的报表参数。我的 RenderBegin 处理程序如下所示:
但这会引发另一个问题:如何让报表使用新参数重新呈现自身以响应用户交互?例如,在我的例子中,我设置了一个主从页面,左侧是 RadTreeListView,右侧是 ReportViewer。每次所选项目发生更改时,我都需要让 ReportViewer 重新计算自身。
ReportViewer 没有方法强制重新渲染。设置其 Report 属性不会执行任何操作,因为如果您更改的只是参数,则每次 Report 字符串都将相同。
我的黑客解决方案是当我想要强制更改时设置 ReportServiceUri 属性。
肯定有更好的方法,但这应该可以帮助您前进。
If you define a handler for the ReportViewer's RenderBegin event, you receive a RenderBeginEventArgs parameter with an empty NameValueDictionary property called ParameterValues.
You can Add {name, value} pairs to this collection and they seem to finish up in the Parameters collection of the Report.
For example, I have two report parameters named "InputElementID" and "ReportPeriod". My RenderBegin handler looks something like the following:
But this will raise another issue: How do you get the report to re-render itself with new parameters in response to user interaction? For example, in my case I had a master-detail page set up, with a RadTreeListView on the left and my ReportViewer on the right. I needed to get my ReportViewer to re-compute itself every time the selected item changed.
The ReportViewer has no methods to force a re-render. And setting its Report property does nothing, as the Report string will be the same every time if all you're changing is the parameter.
My hacky solution was to set the ReportServiceUri property when I wanted to force a change.
There must surely be a better way, but this should get you going.