Home > Web Front-end > JS Tutorial > body text

High-performance TreeView supplement based on JQUERY in ASP.NET_jquery

WBOY
Release: 2016-05-16 18:10:22
Original
917 people have browsed it

The complete code is posted below. I took a lot of detours because I read the codes of friends in the replies. Now that I think about it, it doesn’t have to be that troublesome.

Copy code The code is as follows:




Backend
Copy code The code is 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;
}
//Recursive
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;
}
}

In the end, everyone can just build the database. Thanks again for being unfair. elder brother
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template