This is a migrated thread and some comments may be shown as answers.

Filtering rows in crosstab

1 Answer 331 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ubaldo
Top achievements
Rank 1
Ubaldo asked on 31 Aug 2011, 11:24 AM
Hi there,
the goal that I need to reach is to hide a specific group total row in a crosstab report, based on the value of a field.
With reference to the attached picture, I want that row number 3 (the first group total row) is not visible.
Just to be more clear, it is like if in the "Product Sales per Period" sample report I want to hide the "totals" row when the main category is "Accessories".
I've tried in code behind with this, but only the color style works:
Private Sub Crosstab1_ItemDataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles Crosstab1.ItemDataBound
  Dim table As Telerik.Reporting.Processing.Table = DirectCast(sender, Telerik.Reporting.Processing.Table)
  For Each row As Telerik.Reporting.Processing.TableRow In table.Rows
    If row.Index = 3 Then
      For colIndex As Integer = 0 To table.Columns.Count - 1
        Dim cell As Telerik.Reporting.Processing.ITableCell = row.GetCell(colIndex)
        If cell.RowIndex = row.Index AndAlso cell.ColumnIndex = colIndex Then
          Dim item As Telerik.Reporting.Processing.ReportItem = cell.Item
          If TypeOf (item) Is Processing.TextBox Then
            Dim txt As Processing.TextBox = DirectCast(item, Processing.TextBox)
            item.Visible = False  'does not work
            txt.Visible = False 'does not work
            txt.Height = New Telerik.Reporting.Drawing.Unit(0)  'does not work
            txt.Style.Color = Color.Red 'it works !
          End If
        Else
          ' Do nothing. This is part of a merged table cell
        End If
      Next
    End If
  Next
End Sub

I've tried to use a Filtering expression for the crosstab, but if apply an expression on the main category field, obviously the WHOLE group gets hidden/displayed, not just the totals row of that group. (NOTE: using the operator Not Like generates an error when previewing, while the same filter with Like operator works. Is it correct ? - see attachment 2)

Please explain me how can I have control over the row of a crosstab, maybe with an example.
I'm using Reporting Q2_2011_v5_1_11_713
TIA
Ubaldo

1 Answer, 1 is accepted

Sort by
0
Hrisi
Telerik team
answered on 05 Sep 2011, 08:48 AM
Hi Ubaldo,

In the Table (Crosstab/List) report items you cannot hide rows/columns by changing Visibility properties of the containing report items in the cells. The rows/columns are not report items and they appear only when the corresponding RowGroup/ColumnGroup member is present. Thus in order to hide a "row" you should filter the corresponding RowGroup members, i.e. the only way to hide the group total row is to filter it.

Before doing this, please note that the row group members and the total row are siblings in the row group hierarchy, i.e they have same parent. From the ProductSales report in our examples you can see that SubCategory group and Total group (static) are in the same level in the hierarchy and their parent is Category group (see SubCategoryLevel.png). On CategoryGroupLevel.png screenshot, the parent is the Crosstab itself.

If we want to hide the total row for the SubCategory group contained in Category group "Accessories" member the filter applied to the static group will look as shown in FilterSUbCategoryTotal.png. Please note we use Substr() function instead of "Not Like" operator, because this is a known bug for which the fix will be provided in the upcoming SP1 release.

You can also use Substr function in your filter expression and I hope this will achieve the desired result.

All the best, Hrisi

the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
General Discussions
Asked by
Ubaldo
Top achievements
Rank 1
Answers by
Hrisi
Telerik team
Share this question
or