遍历报表的各列以动态显示/隐藏它们吗?
我想尝试实现一个参数,该参数将允许用户动态选择要在报告中显示的列.一个想法是创建一个具有列名的多值参数.用户点击查看报告后,我想尝试对列和所选值进行迭代以加入可见性.
I want to try and implement a parameter which will allow users to dynamically choose which columns are going to be shown in a report. An idea is to create a multiple value parameter which has column names. After user hit View Report I want to try iterate over columns and selected values to join visibility.
如何遍历tablix中的列?
How I can iterate over columns inside a tablix?
如何遍历参数的多个值,以便确定是否选择了某个值?
How I can iterate over multiple values of a parameter, so I can find if some value is selected or not?
我正在使用MS SQL Reporting Services 2012.
I am using MS SQL Reporting Services 2012.
对于表(即固定列),可以使用以下方法.它并不是真正基于循环,而是基于参数选择对每列进行单独的可见性检查.
For a table, i.e. fixed columns, you can use the following approach. It's not really loop based so much as an individual distinct visibility check for each column based on a parameter selection.
设置一个多值参数,该参数列出了可以显示/隐藏的列.
Set up a multi-valued parameter that lists the columns that can be displayed/hidden.
然后,针对实际表中的每个列,将列可见性设置为使用基于参数的表达式:
Then, for each of these columns in the actual table, set the Column Visibility to use an expression based on the parameter:
表达式类似于:
=IIf(InStr(Join(Parameters!IncludedColumn.Value, ","), "Col1") > 0, false, true)
这是在为 IncludedColumn 参数构造一个所有选定值的字符串,然后检查是否包含特定的列标识符;此特定列的 Col1 .您将为每列使用不同的常量.
What this is doing is constructing a string of all selected values for the IncludedColumn parameter, then checking if a certain column identifier is included; Col1 for this particular column. You'd use different constants for each column.
因此,在运行报表时,此方法可以基于参数选择来隐藏/显示列.
So when running the report this approach can hide/display columns based on a parameter selection.
所有选定的列:
已选择某些列: