Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
450
Ultragrid Summary Row - Ignores hidden rows on grid
posted

Hi,

I have a ultragrid that has a summary row. I also implemented hide/unhide row functionality as part of requirement. Now here the issue - when i hide the rows on gird it also affecting the summary row at the bottom i.e. .Sum is ignoring the values of hidden row its only calculating what’s visible on grid.

I also tried implementing ICustomSummaryCalculator but there also i'm not getting reference of hidden row!

Is there any setting/property to through i can tell summary field to consider hidden rows for sum?

Thanks

Venkatesh

Parents
No Data
Reply
  • 5
    Suggested Answer
    Offline posted

    I had the same problem and found a way to do it using a custom summary type. Essentially when you implement the ICustomSummaryCalculator, add a constructor to the class and pass in the grid by reference. Don't do anything in the AggregateCustomSummary method because it only sees the visible rows. Instead do a loop through of the passed-in grid in the EndCustomSummary method. This makes your grid available to your custom class and you can do anything with it inside the custom calculator.

    Public Class MyCustomSummary
        Implements InfraWinGrid.ICustomSummaryCalculator

        Private m_pGrid As InfraWinGrid.UltraGrid

        Public Sub New(ByRef pGrid As InfraWinGrid.UltraGrid)
            m_pGrid = pGrid
        End Sub

        Public Sub BeginCustomSummary(ByVal summarySettings As InfraWinGrid.SummarySettings, ByVal rows As InfraWinGrid.RowsCollection) Implements InfraWinGrid.ICustomSummaryCalculator.BeginCustomSummary
        End Sub

        Private Sub AggregateCustomSummary(ByVal summarySettings As InfraWinGrid.SummarySettings, ByVal row As InfraWinGrid.UltraGridRow) Implements InfraWinGrid.ICustomSummaryCalculator.AggregateCustomSummary
            'Do nothing
        End Sub

        Private Function EndCustomSummary(ByVal summarySettings As InfraWinGrid.SummarySettings, ByVal rows As InfraWinGrid.RowsCollection) As Object Implements InfraWinGrid.ICustomSummaryCalculator.EndCustomSummary
            Dim intPos As Sys.Int32 = summarySettings.SourceColumn.Index
            Dim decSum As Decimal

            If intPos >= m_decONUninvested.Length Then intPos = m_decONUninvested.Length - 1

            For Each pRow As InfraWinGrid.UltraGridRow In m_pGrid.Rows
                If pRow.Cells(intPos).Value IsNot Sys.DBNull.Value Then
                    decSum += FedCmsCommUtil.ToDecimal(pRow.Cells(intPos).Value)
                End If
            Next pRow

            Return decSum
        End Function
    End Class

Children
No Data