SQL 基于其他参数结果的 SSRS 灰显参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16691210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SSRS Grey out Parameter based on result from other Parameter
提问by Zakerias
I wondered if it was possible to grey out a parameter based on the the result from another parameter? In this case, if specify date is set to 'No' then Start Date and End Date should be greyed out.
我想知道是否可以根据另一个参数的结果使参数变灰?在这种情况下,如果指定日期设置为“否”,则开始日期和结束日期应为灰色。
As you can see from the screenshot this hasn't happened, despite setting Specify Date to either Yes or No - start date and end date will expect a value (unless you tick the NULL value). The report will run fine if both the NULL boxes are ticked beside both the start and end dates - but if they are automatically greyed out based on 'No' it will make the process a lot easier for users.
正如您从屏幕截图中看到的,尽管将“指定日期”设置为“是”或“否”,但并未发生这种情况 - 开始日期和结束日期需要一个值(除非您勾选 NULL 值)。如果在开始日期和结束日期旁边都勾选了两个 NULL 框,则报告将运行良好 - 但如果它们根据“否”自动变灰,则用户的过程将变得更加容易。
So in short, if 'No' dates greyed out, if 'Yes' display. Is this possible? and if so how?
简而言之,如果“否”日期变灰,如果“是”显示。这可能吗?如果是这样怎么办?
Many thanks in advance for any replies
非常感谢您的任何答复
回答by StevenWhite
Within the confines of what's built-in, you can use this method:
在内置内容的范围内,您可以使用此方法:
Create a dataset that is based on your SpecifyDate parameter.
if @SpecifyDates = 'No' select null as Date else select cast('1/1/2012' as datetime) as Date
Set the default values for your dates to be based on this dataset.
创建基于指定日期参数的数据集。
if @SpecifyDates = 'No' 选择 null 作为日期 else select cast('1/1/2012' as datetime) as Date
将日期的默认值设置为基于此数据集。
When you choose "No" for specify dates, the dates will be set to Null, greyed out, and not required to run the report. When you select "Yes" it will put in the default date that you set in the query. Of course you can customize that.
当您为指定日期选择“否”时,这些日期将设置为 Null、灰显且不需要运行报告。当您选择“是”时,它将输入您在查询中设置的默认日期。当然,您可以自定义它。
回答by BlakeH
There's not too much customization you can do with the SSRS parameter widgets.
您可以使用 SSRS 参数小部件进行太多自定义。
What I have seen and done in the past to achieve this type of functionality was to code our own html/js forms and have them submit the parameters to the report. This does result in having to maintain extra code, but when it is required and not supported, you have to go outside the box.
我在过去看到和完成的实现这种类型的功能是编写我们自己的 html/js 表单并让它们将参数提交给报告。这确实导致必须维护额外的代码,但是当需要但不支持时,您必须跳出框框。
That being said, I am curious to see what anyone else would suggest.
话虽如此,我很想知道其他人会提出什么建议。