Seeing that yuanyou published an article about the JS tree, after reading it, I thought it was possible to streamline a lot of code,
I thought that a JS tree was used in the previous project, so I tried to modify it. Now I have posted the code to share it with you. I also ask you to throw more bricks!
<! DOCTYPE html PUBLIC "-// W 3C // Dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> </title>
<Script src = "JS/Tree. js" type = "text/javascript"> </script>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<% -- <Asp: TreeView ID = "TreeView1" runat = "server" ShowLines = "True">
</Asp: TreeView> -- %>
<Div id = "treeOrgan"> </div>
</Div>
</Form>
<Script type = "text/javascript" language = "javascript">
Var tree;
Window. onload = function ()
{
If (tree! = ""){
Tree = new treeview ("treeview", "../images/Tree", false, false );
Var parNode = new node ("personnel list", "personnel list", "", "0", "F", false ,"");
// Caption, title, url, target, tag, check, callback
Tree. add (parNode );
Tree. create (document. getElementById ("treeOrgan "));
InitNode (0, parNode );
ParNode. expand ();
}
}
Function InitNode (id, parNode ){
If (parNode. nodes. length> 0 ){
ParNode. toggle ();
}
Else {
// ParNode. DeleteChildren ();
Var result = WebApplicationJsTree. _ Default. GetJson (id). value;
If (result! = Null & result! = ""){
Var data = eval ('+ result + ')');
For (var I = 0; I <data. length; I ++ ){
Var pn = new node (data [I]. NAME, data [I]. NAME, "", "P", data [I]. id, true ,"");
ParNode. add (pn );
}
}
}
}
Treeview. prototype. onnodeclick = function (sender ){
InitNode (sender. tag, sender );
Sender. select ();
Sender. expand ();
Return false;
}
</Script>
</Body>
</Html>
In fact, I personally think that using TreeView + linq to list will connect to the server once, and the performance of small data volumes should be quite high. The Code is also in the source package.
In the interaction with the client, you can add
Tn. Text = "<span onclick = \" treeNodeClick ("+ tn. ID +") \ ">" + tn. Name;
Database Structure:
FF: