以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]带目录树节点的动态筛选并分页加载  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=89673)

--  作者:ajie5211
--  发布时间:2016/8/26 16:39:00
--  [求助]带目录树节点的动态筛选并分页加载

Dim txt As String = e.Form.Controls("过滤值").Text
Dim tbl As DataTable = DataTables("tabDIYTable24")
Dim sxxm As String = e.Form.Controls("过滤项目").text
Dim ftxt As String
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim tb As WinForm.TreeNode = trv.SelectedNode
Dim i As Integer = tb.Level
If txt = "" And tb.Text <> "所有分类" And i = 0 Then
    ftxt = "F128" & " = " & tb.Text
Else If txt = "" And tb.Text <> "所有分类" And i = 1 Then
    ftxt = "F128" & " = " & tb.ParentNode.Text & "F126" & " = " & tb.Text
Else If txt <> "" And tb.Text <> "所有分类" And i = 0 Then
    txt = "\'%" & txt & "%\'"
    For Each cl As DataCol In DataTables("tabDIYTable24").DataCols
        If cl.Caption = sxxm Then
            ftxt = cl.Name & " Like " & txt & "F128" & " = " & tb.Text
        End If
    Next
Else If txt <> "" And tb.Text <> "所有分类" And i = 1 Then
    txt = "\'%" & txt & "%\'"
    For Each cl As DataCol In DataTables("tabDIYTable24").DataCols
        If cl.Caption = sxxm Then
            ftxt = cl.Name & " Like " & txt & "F128" & " = " & tb.ParentNode.Text & "F126" & " = " & tb.Text
        End If
    Next
Else If  txt <> "" And tb.Text = "所有分类" Then
    txt = "\'%" & txt & "%\'"
    For Each cl As DataCol In DataTables("tabDIYTable24").DataCols
        If cl.Caption = sxxm Then
            ftxt = cl.Name & " Like " & txt
        End If
    Next
Else
    ftxt = ""
End If
With DataTables("tabDIYTable24")
    .LoadFilter = ftxt \'一定要清除加载条件
    .LoadTop = 15
    .LoadPage = 0
    .Load()
End With

上面代码要么提示F128处语法错误,要么提示未将对像引用设置到对像的实例,求解决方法并简化代码。F128和F126是表tabDIYTable24中的列名。


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20160826163618.png
图片点击可在新窗口打开查看

--  作者:大红袍
--  发布时间:2016/8/26 17:04:00
--  
Dim txt As String = e.Form.Controls("过滤值").Text
Dim tbl As DataTable = DataTables("tabDIYTable24")
Dim sxxm As String = e.Form.Controls("过滤项目").text
Dim ftxt As String
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim tb As WinForm.TreeNode = trv.SelectedNode
Dim i As Integer = tb.Level
If txt = "" And tb.Text <> "所有分类" And i = 0 Then
    ftxt = "F128" & " = \'" & tb.Text & "\'"
Else If txt = "" And tb.Text <> "所有分类" And i = 1 Then
    ftxt = "F128" & " = \'" & tb.ParentNode.Text & "\' and F126" & " = \'" & tb.Text & "\'"
Else If txt <> "" And tb.Text <> "所有分类" And i = 0 Then
    txt = "\'%" & txt & "%\'"
    For Each cl As DataCol In DataTables("tabDIYTable24").DataCols
        If cl.Caption = sxxm Then
            ftxt = cl.Name & " Like " & txt & " and F128" & " = \'" & tb.Text & "\'"
        End If
    Next
Else If txt <> "" And tb.Text <> "所有分类" And i = 1 Then
    txt = "\'%" & txt & "%\'"
    For Each cl As DataCol In DataTables("tabDIYTable24").DataCols
        If cl.Caption = sxxm Then
            ftxt = cl.Name & " Like " & txt & " and F128" & " = \'" & tb.ParentNode.Text & "\' and F126" & " = \'" & tb.Text & "\'"
        End If
    Next
Else If  txt <> "" And tb.Text = "所有分类" Then
    txt = "\'%" & txt & "%\'"
    For Each cl As DataCol In DataTables("tabDIYTable24").DataCols
        If cl.Caption = sxxm Then
            ftxt = cl.Name & " Like " & txt
        End If
    Next
Else
    ftxt = ""
End If
With DataTables("tabDIYTable24")
    .LoadFilter = ftxt \'一定要清除加载条件
    .LoadTop = 15
    .LoadPage = 0
    .Load()
End With

--  作者:ajie5211
--  发布时间:2016/8/27 9:05:00
--  

非常感谢!这一个窗口做了一周,真不容易。