Foxtable(狐表)用户栏目专家坐堂 → 用列名作为筛选树节点名,怎样做截图那样


  共有8519人关注过本帖树形打印复制链接

主题:用列名作为筛选树节点名,怎样做截图那样

帅哥,在线噢!
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106079 积分:539494 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/18 21:57:00 [显示全部帖子]

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")

For Each c As Col In Tables("表A").Cols
    Dim n As WinForm.TreeNode = trv.Nodes.Add(c.Name,c.Name)
    For Each c2 As String In DataTables("表A").GetValues(c.Name,c.Name & " is not null")
        n.Nodes.Add(c2,c2)
    Next
Next

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106079 积分:539494 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/19 9:10:00 [显示全部帖子]

dim str() as string = {"某列1","某列2"}
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")

For Each c As string In str
    Dim n As WinForm.TreeNode = trv.Nodes.Add(c,c)
    For Each c2 As String In DataTables("表A").GetValues(c,c & " is not null")
        n.Nodes.Add(c2,c2)
    Next
Next

 回到顶部
帅哥,在线噢!
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106079 积分:539494 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/19 11:19:00 [显示全部帖子]

Dim Filter As String
Dim d1 As String
Dim dr As DataRow = e.Node.DataRow '获取生成此节点的行
If e.Node.Text <> "显示所有行" Then
    Select Case e.Node.Level
        Case 1
            Filter = e.Node.ParentNode.Text & " = '" & e.Node.Text & "'"
    End Select
End If
Tables("表A").Filter = Filter

 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106079 积分:539494 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/19 14:25:00 [显示全部帖子]

e.Node.ParentNode.Text是列名,e.Node.Text是值

msgbox(Filter )看看就知道了

 回到顶部
帅哥,在线噢!
有点蓝
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106079 积分:539494 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/19 20:31:00 [显示全部帖子]

For Each c As String In str
    Dim n As WinForm.TreeNode = trv.Nodes.Add(c,c)
    For Each c2 As String In DataTables("表A").GetValues(c,c & " is not null")
        n.Nodes.Add(c2,c2 & "(" & DataTables("表A").Compute("count(姓名)",c & "='" & c2 & "'") & "人)")
    Next
Next

 回到顶部
帅哥,在线噢!
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106079 积分:539494 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/19 22:51:00 [显示全部帖子]

Dim Filter As String
Dim d1 As String
Dim dr As DataRow = e.Node.DataRow '获取生成此节点的行
'If e.Node.Text <> "显示所有行" Then
    Select Case e.Node.Level
        Case 1
            Filter = e.Node.ParentNode.Text & " = '" & e.Node.Text.Split("(")(0) & "'" 
    End Select
'End If
Tables("表A").Filter = Filter

 回到顶部
帅哥,在线噢!
有点蓝
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106079 积分:539494 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/20 15:02:00 [显示全部帖子]

afterload
Dim str() As String = {"部门","性别"} '定义筛选树中显示的列名
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")

trv.Nodes.Insert("显示所有行",0)

For Each c As String In str
    Dim n As WinForm.TreeNode = trv.Nodes.Add(c,c)
    For Each c2 As String In DataTables("表A").GetValues(c,c & " is not null")
        'n.Nodes.Add(c2,c2)
        n.Nodes.Add(c2,c2 & "(" & DataTables("表A").Compute("count(部门)",c & "='" & c2 & "'") & "人)")
    Next
Next
Dim n2 As WinForm.TreeNode = trv.Nodes.Add("出生日期","出生日期")
For Each c2 As String In DataTables("表A").SQLGetValues("year(出生日期)","出生日期 Is not null")
    Dim y As Date = new Date(cint(c2),1,1)
    n2.Nodes.Add(c2,c2 & "(" & DataTables("表A").Compute("count(出生日期)","出生日期>=#" & y & "# and 出生日期 < #" & y.AddYears(1) & "#") & "人)")
Next

查询
Dim Filter As String
Dim d1 As String
'Dim dr As DataRow = e.Node.DataRow '获取生成此节点的行

Select Case e.Node.Level
    Case 1
        If e.Node.ParentNode.Text = "出生日期" Then
            Dim y As Date = new Date(cint(e.Node.Text.Split("(")(0)),1,1)
            Filter = "出生日期 >= #" & y & "# and 出生日期 < #" & y.AddYears(1) & "#"
        Else
            Filter = e.Node.ParentNode.Text & " = '" & e.Node.Text.Split("(")(0) & "'"
        End If
End Select

Tables("表A").Filter = Filter

 回到顶部
帅哥,在线噢!
有点蓝
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106079 积分:539494 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/21 11:51:00 [显示全部帖子]

Tables("基本信息").filter = Lis & " like '%" & Fin & "%'"

 回到顶部
帅哥,在线噢!
有点蓝
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106079 积分:539494 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/21 17:58:00 [显示全部帖子]

参考日期的用法单独处理,筛选的时候,判断包含以下2个字就:Filter = “工资 <= 1000"
其它的就按照分隔符拆分

dim ar() as string = e.node.text.split("-")
Filter = "工资 >= " & ar(0) & " and 工资 <= " & ar(1)

 回到顶部
帅哥,在线噢!
有点蓝
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106079 积分:539494 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/24 21:21:00 [显示全部帖子]

上传实例

 回到顶部
总数 40 1 2 3 4 下一页