Asp. jquery-based High performance TreeView supplemental _jquery in net

Source: Internet
Author: User
The following is a complete code, I walked a lot of detours, the reason is to see the reply to the Code of Friends, now think of it actually need not so much trouble.
Copy Code code as follows:

<script src= "Js/jquery-1.4.2.min.js" type= "Text/javascript" ></script>
<script src= "Js/jquery.mytree.js" type= "Text/javascript" ></script>
<link href= "Second.css" rel= "stylesheet" type= "Text/css"/>
<script type= "Text/javascript" >
$ (function () {
var o = {Showcheck:true};
O.data =<%=treenodes%>;
$ ("#tree"). TreeView (O);
})
</script>

Background
Copy Code code as follows:

public string Getfirjson ()
{
String mystr = "[";
DataTable dt = DBUtility.db.ExecuteTable ("SELECT * from class where parientid=0");
int a = dt. Rows.Count;
for (int i = 0; I <= dt. rows.count-1; i++)
{
MyStr + = Getotherjson (Convert.ToInt32 (dt. rows[i]["ClassID"]. ToString ()) + ",";
}
MyStr = mystr. Substring (0, MyStr. LENGTH-1);
MyStr + = "]";
MyStr = mystr. Replace ("'", "\");
return mystr;
}
Recursion
private string Getotherjson (int pid)
{
DataTable dt = DBUtility.db.ExecuteTable ("SELECT * from class where classid=" + pid);
String Strjson = "";
BOOL Haschild = Ishaschild (PID);
Strjson = "{";
Strjson + = "' id ': '" + pid + "',";
Strjson + = "' Text ': '" + dt. rows[0]["ClassName"]. ToString () + "',";
Strjson + = "' Value ': '" + dt. rows[0]["ClassID"]. ToString () + "',";
Strjson + = "' Showcheck ': true,";
Strjson + = "' Complete ': true,";
Strjson + = "' Checktate ': 0,";
Strjson + = "' HasChildren ':" + haschild. ToString (). ToLower () + ",";
Strjson + = "' childnodes ':";
if (! Ishaschild (PID))
{
Strjson + = "null}";
}
Else
{
Strjson + = "[";
DataTable myDT = DBUtility.db.ExecuteTable ("SELECT * from class where parientid=" + pid);
for (int i = 0; I <= mydt. rows.count-1; i++)
{
Strjson + = Getotherjson (Convert.ToInt32 (myDT. rows[i]["ClassID"]. ToString ()) + ",";
}
Strjson = Strjson. Substring (0, Strjson. LENGTH-1);
Strjson + = "]}";
}
return Strjson;
}
private bool Ishaschild (int pid)
{
DataTable dt = DBUtility.db.ExecuteTable ("SELECT * from class where parientid=" + pid);
if (dt. Rows.Count = 0)
{
return false;
}
Else
{
return true;
}
}

The final database we'll just look at the building. Thanks again for the indecent brother.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.