devexpress vb.net在每个节点级别上的treelist组摘要

时间:2017-05-15 04:01:35

标签: vb.net devexpress summary treelist

那里。我是一家制造公司的内部Vb.net程序员。这是一个中小企业。我正在使用devexpress vb.net升级COA(账户图表),具体来说,我利用treelist组件来显示COA。

不幸的是,该组件并未总结所有节点。

如果有人可以帮助我,我真的很感激。

我创建了一个简短版本的COA显示VB.net代码和执行形式的屏幕截图。

Imports DevExpress.Data

Public Class Form1
    Dim DataTable1 As New DataTable

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        DataTable1.Columns.Add("NodeIDParent", GetType(String))
        DataTable1.Columns.Add("NodeID", GetType(String))
        DataTable1.Columns.Add("NodeName", GetType(String))
        DataTable1.Columns.Add("NodeValue", GetType(Integer))

        DataTable1.Rows.Add("", "01", "Node One", 0)

        DataTable1.Rows.Add("01", "03", "Node One One", 0)
        DataTable1.Rows.Add("03", "07", "Node One One One", 0)
        DataTable1.Rows.Add("07", "08", "Node One One One One", 6)
        DataTable1.Rows.Add("07", "09", "Node One One One Two", 7)
        DataTable1.Rows.Add("07", "10", "Node One One One Tree", 8)

        DataTable1.Rows.Add("01", "04", "Node One Two", 0)
        DataTable1.Rows.Add("04", "05", "Node One Two One", 2)
        DataTable1.Rows.Add("04", "06", "Node One Two Two", 5)

        DataTable1.Rows.Add("", "02", "Node Two", 0)

        With TreeList1
            .DataSource = DataTable1

            .OptionsView.ShowRowFooterSummary = True
            .Columns("NodeValue").RowFooterSummary = SummaryItemType.Sum

            .OptionsView.ShowSummaryFooter = True
            .Columns("NodeValue").SummaryFooter = SummaryItemType.Sum

            .Columns("NodeValue").AllNodesSummary = True

            .ParentFieldName = "NodeIDParent"
            .KeyFieldName = "NodeID"
        End With
    End Sub
End Class

enter image description here

1 个答案:

答案 0 :(得分:0)

试试这段代码:

 Dim item As GridGroupSummaryItem = New GridGroupSummaryItem()
        item.FieldName = Grid.Columns("NodeValue").FieldName
        item.SummaryType = DevExpress.Data.SummaryItemType.Sum
        item.ShowInGroupColumnFooter = Grid.Columns("NodeValue")
        item.DisplayFormat = "{0:#,##0.00}"

 Grid.GroupSummary.Add(item)