加一列排序列,取巧处理。
Dim t As Table = Tables("订单")
If t.Cols.Contains("总金额") = False
t.DataTable.DataCols.Add("总金额", Gettype(Double))
End If
For Each kh As String In t.DataTable.GetValues("客户")
t.DataTable.ReplaceFor("总金额", t.DataTable.Compute("sum(金额)", "客户 = '" & kh & "'"), "客户 = '" & kh & "'")
Next
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = True
t.SpillNode = True
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "总金额"
g.TotalOn = "金额"
g.Caption = "{0} 小计"
t.SubtotalGroups.Add(g)
t.Subtotal
Dim r As Row
For i As Integer = 0 To t.Rows.Count(True) - 1
r = t.Rows(i,True)
If r.IsGroup
r("产品") = t.Rows(i-1,True)("客户")
End If
Next
t.Grid.Tree.Show(0)