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

Conditional Formatting of details based on group footer aggregates

2 Answers 167 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lukas
Top achievements
Rank 2
Lukas asked on 15 Feb 2011, 01:09 PM
Hello,

I was wondering if the following could be achieved with Telerik Reporting:

I have a list of user data grouped by teams. Each has an amount of emails, the average amount is shown in the group footer e.g.:

USER                  EMAILS                                Group-Header
----------------------------------------------------------------------------------------
User1                        5
User2                        10                                     Detail-Section
User3                        15
--------------------------------------------------------------------------------------------
Team-Avg.                10                                    Group-Footer

Now I want to color User1 red, because he is below average and User3 green, because he is above average

I tried to achieve this by conditional formatting but I could not find out how to reference the Average-Field in the Group-Footer.
I use a Table-Control to display the values in my chart, if this makes any difference.

I also thought about writing this in code-behind but I don't know how to start here either.


Any help is appreciated,

Lukas

2 Answers, 1 is accepted

Sort by
0
Lukas
Top achievements
Rank 2
answered on 15 Feb 2011, 02:55 PM
Ok I think I found a solution doing this in code but now I'm stuck there:

I hook up to the Report_DataBound event and fetch me the processing table object.
In this I iterate through the Table1.ChildElements and get me the Email-Fields and Average-Fields by name:

Private Sub AgentTag_ItemDataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ItemDataBound
          'Get Table-Object
    Dim rpt As Telerik.Reporting.Processing.Report = sender
    Dim details As Telerik.Reporting.Processing.DetailSection = rpt.ChildElements(0).ChildElements(0)
    Dim tbl As Telerik.Reporting.Processing.Table = details.ChildElements.Find("Table1", False)(0)
 
    ''Get all AverageFields
    Dim allAverageFields As Telerik.Reporting.Processing.TextBox() = tbl.ChildElements.Find("txt_AverageField", False)
    ''Get all Email-Amount Field
    Dim allEmailFields = tbl.ChildElements.Find("txt_EmailField", False)
 
    ''Iterate through all fields and check values
    For Each averageField As Telerik.Reporting.Processing.TextBox In allAverageFields
        For Each emailField As Telerik.Reporting.Processing.TextBox In allEmailFields
            If emailField.?GroupID? = averageField.?GroupID? Then  ''How to ensure, that the averageField is from the goup in which the emailField is ???
                If CDec(emailField.Value) >= CDec(averageField.Value) Then
                    emailField.Style.BackgroundColor = Color.Red
                Else
                    emailField.Style.BackgroundColor = Color.Green
                End If
                Exit For
            End If
        Next
    Next
 
End Sub


But in the iteration I could not find a solution how to check if the AverageField is from the correct group as the emailField.
The emailField.Parent refers to the Table1 object, but there seem to be no GroupSections or anything like this within the table object.

Again any help or hint how to proceed is greatly appreciated

thx
Lukas
0
Lukas
Top achievements
Rank 2
answered on 15 Feb 2011, 03:37 PM
Ok again, I found it by myself.
Sometime just writing it down brings you a step further.

If averageField.DataObject.Item("GroupIDFieldFromDB") = emailField.DataObject.Item("GroupIDFieldFromDB") Then
     If CDec(emailField.Value) >= CDec(averageField.Value) Then
         emailField.Style.BackgroundColor = Color.Red
     Else
         emailField.Style.BackgroundColor = Color.Green
     End If
 End If

So you can check if they belong to the same group.

If I find the time I will extract the logic to an external function/class und upload it as a sample, if someone is interested.



Tags
General Discussions
Asked by
Lukas
Top achievements
Rank 2
Answers by
Lukas
Top achievements
Rank 2
Share this question
or