以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]多值列目录树  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=120041)

--  作者:湛江智
--  发布时间:2018/6/6 8:48:00
--  [求助]多值列目录树

\'1、多值列,生成目录树,要增加实现统计数量,代码怎么修改呢?
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each dr As DataRow In DataTables("物料汇总").DataRows
    For Each s As String In dr("项目空间类型").split(",")
        If trv.Nodes.Contains(s) = False Then
            trv.nodes.Add(s)
        End If
    Next
Next

 

\'2、要实现单选,下面代码怎么修改,放在哪个属性事件里面呢?

Dim trv As WinForm.TreeView = e.Sender
Dim flt As String
For Each nd As WinForm.TreeNode In e.node.Nodes \'清除子节点选中状态
    nd.Checked = False
Next
If e.node.ParentNode IsNot Nothing Then \'去掉父节点选中状态
    e.node.ParentNode.Checked = False
End If
For Each nd As WinForm.TreeNode In trv.AllNodes
    If nd.Checked Then
        If flt > "" Then
            flt = flt & " Or "  \'注意用or而不是And
        End If
        flt = flt & "( 项目空间类型 like \'%" & nd.Text & "%\')"
    End If
Next
Tables("物料汇总").Filter = flt

 

 


--  作者:有点甜
--  发布时间:2018/6/6 9:12:00
--  

1、

 

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each dr As DataRow In DataTables("物料汇总").DataRows
    For Each s As String In dr("项目空间类型").split(",")
        If trv.Nodes.Contains(s) = False Then
            Dim nd = trv.nodes.Add(s)

            nd.text = nd.name & "(" & DataTables("物料汇总").compute("sum(数量)", "项目空间类型 like \'%" & s & "%\'") & ")"
        End If
    Next
Next

[此贴子已经被作者于2018/6/6 9:13:39编辑过]

--  作者:有点甜
--  发布时间:2018/6/6 9:13:00
--  

2、

 

Tables("物料汇总").Filter = "项目空间类型 like \'%" & e.node.name & "%\'"


--  作者:湛江智
--  发布时间:2018/6/6 9:37:00
--  回复:(有点甜)1、 Dim trv As WinForm.Tr...

堂主,报错。怎么修改呢?


图片点击可在新窗口打开查看此主题相关图片如下:报错图.jpg
图片点击可在新窗口打开查看


--  作者:有点甜
--  发布时间:2018/6/6 10:00:00
--  

要计算个数的话,sum改成count

 

要计算合计的话,要用sum,列要改成数值列才行


--  作者:湛江智
--  发布时间:2018/6/7 22:04:00
--  回复:(有点甜)要计算个数的话,sum改成count&nbs...
  Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each dr As DataRow In DataTables("物料汇总").DataRows
    For Each s As String In dr("项目空间类型").split(",")
        If trv.Nodes.Contains(s) = False Then
            Dim nd = trv.nodes.Add(s)

            nd.text = nd.name & "(" & DataTables("物料汇总").compute("count(<layer highlight="term-2" class="searchwp-term searchwp-highlight-searchwp-highlighting">数量</layer>)", "项目空间类型 like \'%" & s & "%\'") & ")"
        End If
    Next
Next

坛主,修改成上面代码,目录树节点<layer highlight="term-1" class="searchwp-term searchwp-highlight-searchwp-highlighting">统计</layer>的行数,不对

--  作者:有点甜
--  发布时间:2018/6/7 22:07:00
--  
上传具体实例测试。
--  作者:湛江智
--  发布时间:2018/6/7 22:17:00
--  回复:(有点甜)上传具体实例测试。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:f.foxdb


--  作者:有点甜
--  发布时间:2018/6/7 22:24:00
--  
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each dr As DataRow In DataTables("物料汇总").DataRows
    If dr("项目空间类型") > "" Then
        For Each s As String In dr("项目空间类型").split(",")
            Dim nd As WinForm.TreeNode
            If trv.Nodes.Contains(s) = False Then
                nd = trv.nodes.Add(s)
            End If
            nd = trv.nodes(s)
            nd.text = nd.name & "(" & DataTables("物料汇总").compute("count(项目空间类型)", "项目空间类型 like \'%" & s & "%\'") & ")"           
        Next
    End If
Next

--  作者:湛江智
--  发布时间:2018/6/7 22:31:00
--  回复:(有点甜)Dim trv As WinForm.TreeView = e.Fo...
可以了,谢谢坛主,台风还加班