Question

One of the columns in our grid, "EstimateDate" is empty when a job has not been estimated.

Therefore to get a count in the summary of the number of estimated jobs in the grid, it is necessary to count the number of rows where "EstimateDate" is not null.

I believe I need to handle CustomSummaryCalculate but how do I check if that particular column is empty?

Fwiw, this is not the only column I need to do this for and it is not the grid's KeyField either. I already checked out this solution which did not apply. (http://www.devexpress.com/Support/Center/Question/Details/Q507778)

Thanks!

Was it helpful?

Solution

Here is how I ended up solving the problem:

Dim leadcount, estimatecount, bookedcount, completedcount As Integer

Protected Sub ASPxGridView1_CustomSummaryCalculate(ByVal sender As Object, ByVal e As DevExpress.Data.CustomSummaryEventArgs) Handles ASPxGridView1.CustomSummaryCalculate

    Try
        'Summary items are defined by the tag set in the summary item in the summary section of the aspx page
        Dim SummaryItem As String = (TryCast(e.Item, ASPxSummaryItem)).Tag

        Select Case SummaryItem

            Case "LeadDate"
                Cust_Calc_Count_Not_Empty(sender, e, leadcount)
            Case "EstimateDate"
                Cust_Calc_Count_Not_Empty(sender, e, estimatecount)
            Case "BookDate"
                Cust_Calc_Count_Not_Empty(sender, e, bookedcount)
            Case "CompletedDate"
                Cust_Calc_Count_Not_Empty(sender, e, completedcount)

        End Select

    Catch ex As Exception

    End Try

End Sub






Sub Cust_Calc_Count_Not_Empty(ByVal sender As Object, e As DevExpress.Data.CustomSummaryEventArgs, ByRef counter As Integer)

    Try
        Dim item As ASPxSummaryItem = TryCast(e.Item, ASPxSummaryItem)

        ' Initialize summary
        If e.SummaryProcess = DevExpress.Data.CustomSummaryProcess.Start Then
            counter = 0
        End If

        ' Perform calculations
        If e.SummaryProcess = DevExpress.Data.CustomSummaryProcess.Calculate Then
            If (e.FieldValue.ToString <> "") Then
                counter = counter + 1
            End If
        End If

        ' Save results
        If e.SummaryProcess = DevExpress.Data.CustomSummaryProcess.Finalize Then
            e.TotalValue = String.Format("{0}", counter)
        End If

    Catch ex As Exception

    End Try

End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top