隐藏的动态矩阵组在 SSRS 2005 中仍然占据空间

发布于 2024-09-26 21:07:24 字数 3361 浏览 1 评论 0原文

问题

我正在使用动态矩阵组,如动态分组 来自 Chris Hays 的 Reporting Services Sleazy Hacks 博客(顺便说一下,其中有一些很棒的内容,值得一看)。我将行组和列组绑定到两个多值参数,除了一件事之外,一切都运行良好。尽管我禁止显示未使用的组,但它们仍然占用空间。

这是当我仅选择一个行组和一个列组时报告现在的样子:

问题

有谁知道如何在隐藏相应的矩阵组时使空白区域缩小?

仅供好奇(不是问题的一部分)

作为参考,以下是布局模式下矩阵的外观:

矩阵的布局视图

如果其他人想做这样的动态矩阵组,这里是执行繁重工作的代码部分:

Public Function ValueIsInMultiParameter(MultiParameter As Parameter, Value As String) As Boolean
   Dim i as Long
   For i = 0 to MultiParameter.Count - 1
      If MultiParameter.Value(i) = Value Then Return True
   Next
   Return False
End Function

Public Function DynamicFieldValue(CurrentFields As Fields, MultiParameter As Parameter, Index As Long) As Object
   If ParameterCount(MultiParameter) - 1 < Index Then Return ""
   Return CurrentFields(MultiParameter.Value(Index)).Value
End Function

Public Function DynamicFieldFormattedValue(CurrentFields As Fields, MultiParameter As Parameter, Index As Long) As Object
   If ParameterCount(MultiParameter) - 1 < Index Then Return ""
   Return CustomFormat(CurrentFields(MultiParameter.Value(Index)).Value, MultiParameter.Value(Index))
End Function

Public Function DynamicGrouping(MultiParameter As Parameter, Index As Long) As Object
   If ParameterCount(MultiParameter) - 1 < Index Then Return "None"
   Return MultiParameter.Value(Index)
End Function

Public Function DynamicGroupingLabel(CurrentFields As Fields, MultiParameter As Parameter, Index As Long) As String
   If Index = 0 Then Return "Grand Total"
   If ParameterCount(MultiParameter) - 1 < Index Then Return ""
   Return CustomFormat(CurrentFields(MultiParameter.Value(Index - 1)).Value, MultiParameter.Value(Index - 1)) & " Total"
End Function

Public Function CustomFormat(Value As Object, ValueType As String) As String
   Select Case ValueType
      Case "DayOf"
         Return Format(Value, "M/d/yyyy")
      Case "WeekOf"
         Return Format(Value, "M/d/yyyy")
      Case "WeekDayPart"
         Return WeekdayName(Value)
      Case "MonthOf"
         Return Format(Value, "MMM yyyy")
      Case "MonthDayPart"
         Return "Day " & Value
      Case "MonthWeekPart"
         Return "Week " & Value
      Case "YearOf"
          Return Format(Value, "yyyy")
      Case "YearDayPart"
          Return "Day " & Value
      Case "YearWeekPart"
          Return "Week " & Value
      Case "YearMonthPart"
          Return MonthName(Value)
      Case "YearPart"
         Return Value
      Case Else
         Return Value
   End Select
End Function

Public Function ParameterCount(MultiParameter As Parameter) As Long
   If MultiParameter.Count = 0 OrElse MultiParameter.Value(0) = "1" Then Return 0
   Return MultiParameter.Count
End Function

在参数中,我放置了一个可选分组选项的硬编码列表,例如,RowGroups 参数具有可用值:

Label   Value
-----   -------
Year    YearOf
Month   MonthOf
Week    WeekOf
Day     DayOf

其中 Value 是 DataSet 返回的 SQL 列的名称。

The Problem

I am using dynamic matrix groups as in Dynamic Grouping from Chris Hays's Reporting Services Sleazy Hacks Weblog (which has some great stuff and is worth checking out, by the way). I have my row and column groups bound to two multi-value parameters and everything is working great, except for one thing. Even though I am suppressing unused groups from displaying, they are still taking up space.

Here's what the report looks like now when I choose only one row group and one column group:

What the matrix looks like now, with extra space
Notice how even though the undesired groups have property hidden True (as set by an expression) they still take up space. Here's what I'd like it to look like (I cut the blank areas out of the picture by hand):

How I'd like the matrix to look

The Question

Does anyone have any ideas how to make the blank areas shrink when the corresponding matrix groups are hidden?

Just For the Curious (Not part of the question)

For reference, here is what the matrix looks like in Layout mode:

Layout view of the matrix

And if anyone else wants to do dynamic matrix groups like this, here's the code section that does the heavy lifting:

Public Function ValueIsInMultiParameter(MultiParameter As Parameter, Value As String) As Boolean
   Dim i as Long
   For i = 0 to MultiParameter.Count - 1
      If MultiParameter.Value(i) = Value Then Return True
   Next
   Return False
End Function

Public Function DynamicFieldValue(CurrentFields As Fields, MultiParameter As Parameter, Index As Long) As Object
   If ParameterCount(MultiParameter) - 1 < Index Then Return ""
   Return CurrentFields(MultiParameter.Value(Index)).Value
End Function

Public Function DynamicFieldFormattedValue(CurrentFields As Fields, MultiParameter As Parameter, Index As Long) As Object
   If ParameterCount(MultiParameter) - 1 < Index Then Return ""
   Return CustomFormat(CurrentFields(MultiParameter.Value(Index)).Value, MultiParameter.Value(Index))
End Function

Public Function DynamicGrouping(MultiParameter As Parameter, Index As Long) As Object
   If ParameterCount(MultiParameter) - 1 < Index Then Return "None"
   Return MultiParameter.Value(Index)
End Function

Public Function DynamicGroupingLabel(CurrentFields As Fields, MultiParameter As Parameter, Index As Long) As String
   If Index = 0 Then Return "Grand Total"
   If ParameterCount(MultiParameter) - 1 < Index Then Return ""
   Return CustomFormat(CurrentFields(MultiParameter.Value(Index - 1)).Value, MultiParameter.Value(Index - 1)) & " Total"
End Function

Public Function CustomFormat(Value As Object, ValueType As String) As String
   Select Case ValueType
      Case "DayOf"
         Return Format(Value, "M/d/yyyy")
      Case "WeekOf"
         Return Format(Value, "M/d/yyyy")
      Case "WeekDayPart"
         Return WeekdayName(Value)
      Case "MonthOf"
         Return Format(Value, "MMM yyyy")
      Case "MonthDayPart"
         Return "Day " & Value
      Case "MonthWeekPart"
         Return "Week " & Value
      Case "YearOf"
          Return Format(Value, "yyyy")
      Case "YearDayPart"
          Return "Day " & Value
      Case "YearWeekPart"
          Return "Week " & Value
      Case "YearMonthPart"
          Return MonthName(Value)
      Case "YearPart"
         Return Value
      Case Else
         Return Value
   End Select
End Function

Public Function ParameterCount(MultiParameter As Parameter) As Long
   If MultiParameter.Count = 0 OrElse MultiParameter.Value(0) = "1" Then Return 0
   Return MultiParameter.Count
End Function

In the parameters, I put a hard-coded list of selectable grouping options, for example the RowGroups parameter has available values:

Label   Value
-----   -------
Year    YearOf
Month   MonthOf
Week    WeekOf
Day     DayOf

Where the Value is the name of the SQL column as returned by the DataSet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光与爱终年不遇 2024-10-03 21:07:24

我还没有找到解决此问题的任何方法,但是通过有条件地将较低分组项目的颜色设置为与未选择较低分组的较高分组项目的颜色相同,您可以给人一种额外的印象-wide 较高分组的项目,而不是空白旁边的正常大小的项目。

顺便说一句,链接的博客自 2006 年以来似乎就没有更新过。

I haven't found any way around this, but by conditionally setting the colour of the lower-grouped item to be the same as that of the higher-grouped item where there is no lower group selected, you could give the impression of one extra-wide higher-grouped item, instead of a normal-sized item next to a blank.

Incidentally, the linked blog doesn't appear to have been updated since 2006.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文