Unplanned
Last Updated: 17 Dec 2020 10:01 by ADMIN
Nicola
Created on: 17 Dec 2020 09:47
Category: GridView
Type: Bug Report
1
RadGridView: in hierachical grid SummaryRow value is not calculated correctly when grouping by child column
Good Afternoon,

I have a problem with radgridview :

grouping the column (GRP) of child template the summary row contains the correct data (12 RowCount for 62,40 summary), but if I try to sort a column and / or click on the summary row the datas is modified, the RowCount number becomes the total number of groups (4) and the amounts are reset (0,00).

Looking forward to your kind reply, I offer you my best regards.
1 comment
ADMIN
Nadya
Posted on: 17 Dec 2020 10:01

Hello, Nicola,

To work around this issue, you can create a custom GridViewSummaryItem and override its Evaluate method. Thus, you can write your own logic for summary item evaluation:

' CUSTOM SUMMARY ITEMS
Public Class CustomSummaryItem
    Inherits GridViewSummaryItem
    Public Sub New(ByVal name As String, ByVal formatString As String, ByVal aggregate As GridAggregateFunction)
        MyBase.New(name, formatString, aggregate)
    End Sub
    Public Overrides Function Evaluate(ByVal row As IHierarchicalRow) As Object
        Dim total As Decimal = 0
        For Each childRow As GridViewRowInfo In row.ChildRows
            Dim groupRow As GridViewGroupRowInfo = TryCast(childRow, GridViewGroupRowInfo)
            Dim dataRow As GridViewDataRowInfo = TryCast(childRow, GridViewDataRowInfo)

            If groupRow IsNot Nothing Then
                For Each row1 As GridViewRowInfo In groupRow.ChildRows
                    total += (row1.Cells("TOT1").Value)
                Next row1
            ElseIf dataRow IsNot Nothing Then
                total += dataRow.Cells("TOT1").Value
            End If
        Next childRow
        Return total

    End Function
End Class

Public Class CustomSummaryCountItem
    Inherits GridViewSummaryItem
    Public Sub New(ByVal name As String, ByVal formatString As String, ByVal aggregate As GridAggregateFunction)
        MyBase.New(name, formatString, aggregate)
    End Sub
    Public Overrides Function Evaluate(ByVal row As IHierarchicalRow) As Object
        Dim total As Decimal = 0
        For Each childRow As GridViewRowInfo In row.ChildRows
            Dim groupRow As GridViewGroupRowInfo = TryCast(childRow, GridViewGroupRowInfo)
            Dim dataRow As GridViewDataRowInfo = TryCast(childRow, GridViewDataRowInfo)

            If groupRow IsNot Nothing Then
                For Each row1 As GridViewRowInfo In groupRow.ChildRows
                    total += 1
                Next row1
            ElseIf dataRow IsNot Nothing Then
                total += 1
            End If
        Next childRow
        Return total
    End Function
End Class

I hope this helps.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.