简体   繁体   English

SSRS表达式基于文本框或列的可见性

[英]SSRS expression based on visibility of a textbox or column

Is it possible to inspect the visibility (Collapsed/Expanded) of a textbox in SSRS and use this in an expression? 是否可以检查SSRS中文本框的可见性(Collapsed / Expanded)并在表达式中使用它?

For example : 例如 :

=iif(Fields!column1 Is Visible,"Use this label","Use this other label")

What I want to accomplish to have the initial value of a column header display some text, when user clicks a particular value the details row are displayed (this is a Tablix), and then the header would change to something else (Eg initial report state is to hide detail rows and only show Tablix member totals so column displays "... total", when user expands to view details column header changes to "... number". 我想要实现的是使列标题的初始值显示一些文本,当用户单击特定值时显示详细信息行(这是Tablix),然后标题将更改为其他内容(例如,初始报告状态是隐藏详细信息行并仅显示Tablix成员总数,因此列显示“... total”,当用户展开以查看详细信息列标题更改为“... number”时。

In MS Access through VBA I could inspect the visible property and create code based on this. 在通过VBA的MS Access中,我可以检查visible属性并基于此创建代码。 Till now haven't found a similar way of doing this in SSRS 2016. 直到现在还没有在SSRS 2016中找到类似的方法。

Tried setting expressions for visibility as well as setting expressions for changing value of a textbox. 尝试设置可见性表达式以及设置表达式以更改文本框的值。

=IIF(Fields!accountnum.Value IS NOTHING OR Fields!accountnum.Value = TRUE,"Station #", "Station Count")

No error messages. 没有错误消息。 My results should be to change header (textbox) value based on whether detail rows are collapsed (hidden) or expanded (visible). 我的结果应该是根据细节行是折叠(隐藏)还是展开(可见)来更改标题(文本框)值。

I do not think this is possible in SSRS. 我不认为这在SSRS中是可能的。 You could change column header text depending on your condition, For Ex: IF (A) then Header A else Header B. But you wish to change Column Header based on some clicks (expand / collapse) on report and this is not possible. 您可以根据条件更改列标题文本,例如:IF(A)然后标题A否则标题B.但您希望根据报表上的一些点击(展开/折叠)更改列标题,这是不可能的。 I mean we need some data to set condition not clicks. 我的意思是我们需要一些数据来设置条件而不是点击。

But maybe someone with more Experience on SSRS would throw some more insight. 但也许对SSRS有更多经验的人会提出更多的见解。

To answer your first question: 回答你的第一个问题:

Well of course this is possible, just not they way you want to do it. 当然,这是可能的,只是不是你想要的方式。 Here is a smimple example. 这是一个简单的例子。 Lets say your visibilty criteria is the following expression: 让我们说你的可见性标准如下:

'Visibility expression
=IIF(Fields!Category.Value = "Visible", False, True)

Now you dont check on the visibilty with the Is Visible criteria, you just use the same expression again. 现在你不用Is Visible标准检查visibilty,你只需再次使用相同的表达式。 Like this: 像这样:

=IIF(
     IIF(Fields!Category.Value = "Visible", 
         Fale, 
         True) = True, 
 "This one is not visible", 
 "This one is visible")

To answer you problem: 为了回答你的问题:

They way you want to do it, it is not possible. 他们想要这样做,这是不可能的。 But you can do this with a workaround. 但是你可以通过一种解决方法来做到这一点。 Add a user defined parameter to your report with two options: 使用两个选项将用户定义的参数添加到报表中:

  • Display details 显示细节
  • Hide details 隐藏细节

Then add two tablixes to your report. 然后在报表中添加两个Tablix。 One tablix without the details and one tablix with the details you want to show. 一个没有详细信息的tablix和一个tablix,其中包含您要显示的详细信息。 Then go to the first tablix Tablix Properties > Visibility and add the following expression: 然后转到第一个Tablix Tablix Properties> Visibility并添加以下表达式:

=IIF(Parameters!VisibilityParameter.Value = "Display details", True, False)

And the expression for the other tablix visibility: 以及其他Tablix可见性的表达式:

=IIF(Parameters!VisibilityParameter.Value = "Hide details", True, False)  

Now based on the parameter result the talbix with or without the details will be displayed. 现在根据参数结果显示有或没有细节的talbix。

You can do this, maybe it won't look too elegant but I'll show you what I did and you can see if it's useful. 你可以做到这一点,也许它看起来不会太优雅,但我会告诉你我做了什么,你可以看看它是否有用。

Note: Using this method, you can't change the actual column header directly as it's out of scope so this may not meet requirements but you may be able to adapt it. 注意:使用此方法,您无法直接更改实际列标题,因为它超出了范围,因此可能无法满足要求,但您可以对其进行调整。 I just thought it was a nice challenge ! 我只是觉得这是一个很好的挑战! :) :)

First I got some sample data (WideWorldImports sample database) that just gave me a CountryID, CountryName and Continent. 首先,我得到了一些示例数据(WideWorldImports示例数据库),它只给了我一个CountryID,CountryName和Continent。

Once you have your data, add a table, drag CountryName into the first column and remove the remaining two columns. 获得数据后,添加一个表,将CountryName拖到第一列,然后删除剩余的两列。

Then right-click the Details row group and do Add Group => Parent Group Choose Continent as the Group By field and check the Add Group Header option. 然后右键单击“ Details行组并执行“ Add Group => Parent Group选择Continent作为分组依据”字段,并选中“ Add Group Header选项。

The table design should look like this, nice and simple. 表格设计看起来应该像这样,简洁明了。 在此输入图像描述

Next we will set the toggle on the detail rows. 接下来,我们将在详细信息行上设置切换。 Right-Click the "Details" row group and chose "Group Properties". 右键单击“详细信息”行组并选择“组属性”。 On visibility, click 'Hide' and check the "Display Can be toggled by the report item" to Continent . 在可见性上,单击“隐藏”并选中“显示可以由报表项切换”到Continent

We should now have a report that expands and collapses as expected. 我们现在应该有一个按预期扩展和折叠的报告。

Next vertically expand the 'blank cell' just above the countryname as we'll need a bit of room to work with. 接下来,垂直展开国家/地区名称上方的“空白单元格”,因为我们需要一些工作空间。 Make it about 4 times the normal height, we'll change it back later so the size is not important. 使它大约是正常高度的4倍,我们稍后会改回来,所以尺寸并不重要。

In the blank cell, right-click and do Insert => Rectangle . 在空白单元格中,右键单击并执行Insert => Rectangle In this rectangle, right-click and do Insert => TextBox . 在此矩形中,右键单击并执行Insert => TextBox Double click the text box and type your "collapsed state" column header caption. 双击文本框并键入“折叠状态”列标题标题。 In my example I just used "Collapsed Header". 在我的例子中,我只使用了“Collapsed Header”。 Repeat and add another textbox (It must be within the rectangle again). 重复并添加另一个文本框(它必须再次位于矩形内)。 Set this text box to your "expanded state" caption. 将此文本框设置为“展开状态”标题。 In this example I just used "Expanded Header". 在这个例子中,我只使用了“Expanded Header”。

Next, right click the "Collapsed header" textbox, then properties then set the visibility to Show and the toggle item to Continent . 接下来,右键单击“折叠标题”文本框,然后单击属性,将可见性设置为“ Show ,将“切换”项设置为“ Continent

Repeat for your "Expanded Header" but this time set visibilty to Hide , like this.. 重复你的“扩展标题”,但这次设置visibilty Hide ,像这样..

在此输入图像描述

Finally, position both text boxes at location 0,0 so they overlap and shrink the cell back down to it's original size. 最后,将两个文本框放在位置0,0处,使它们重叠并将单元格缩小到原始大小。

The final design will look something like this... 最终的设计看起来像这样......

在此输入图像描述

When we first run the report we see this. 当我们第一次运行报告时,我们会看到这一点

在此输入图像描述

If we expand a node, we get this. 如果我们扩展节点,我们就会得到这个。 在此输入图像描述

This is what InScope() is for. 这就是InScope()的用途。 See here for more information 有关更多信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM