2014-04-03 146 views
0

當未估算作業時,我們網格中的一列「EstimateDate」爲空。在DevExpress中計算非空行AspxGridView摘要

因此,要計算網格中估計作業數量的摘要,需要對「EstimateDate」不爲null的行數進行計數。

我相信我需要處理CustomSummaryCalculate,但如何檢查該特定列是否爲空?

Fwiw,這不是我需要做的唯一的列,它也不是網格的KeyField。我已經檢查了這個不適用的解決方案。 (http://www.devexpress.com/Support/Center/Question/Details/Q507778

謝謝!

回答

0

這裏是我結束瞭解決問題:

昏暗leadcount,estimatecount,bookedcount,completedcount作爲整數

保護小組ASPxGridView1_CustomSummaryCalculate(BYVAL發件人爲對象,BYVALË作爲DevExpress.Data.CustomSummaryEventArgs)句柄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