好好理解了一下递归,发现其实很容易,看来还是要自力更生啊。递归函数AddChildren如下:Dim e As RequestEventArgs = args(0)
Dim nd As string = args(1)
Dim dt As DataTable = args(2)
dim ps2 as list(of string) = args(3)
dim ja as jarray = args(4)
dim i as integer = args(5)
dim ja2 as new jarray
ja(i)("children") = ja2 '
Dim drs2 As List(of DataRow) = dt.SQLSelect("mparent = '" & nd & "'")
dim j as integer = 0
dim counti as integer = 0
For Each dr2 As DataRow In drs2
Dim nd2 As string = dr2("_Identify")
ja2.add(new jobject)
ja2(j)("id") = dr2("_Identify").tostring
ja2(j)("text") = dr2("mname").tostring
if ps2.Contains(dr2("_Identify")) then
ja2(j)("checked") = "true"
counti = counti + 1
end if
Functions.Execute("AddChildren",e,nd2,dt,ps2,ja2,j)
j = j +1
next
if counti <> drs2.count
ja(i)("checked") = ""
end if