easyUI comboTree的实现
本示例用使用visual studio2010开发工具和sql Server数据库制作简单组合树comboTree,大神请绕道,实现的效果图如下:
知识点:easyUI comboTree、一般处理程序、json
制作过程
1.创建一张表,如下图
2.创建一个web 空应用程序,下图为已创建好的应用程序
2.1 添加一个类Unit.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace asp.net_下拉树实现
{
public class Unit
{
public decimal id { get; set; }
public decimal parent_id { get; set; }
public string text { get; set; }
public string state { get; set; }
public List<Unit> children { get; set; }
public Unit()
{
this.children = new List<Unit>();
this.state = "open";
}
}
}
2.2 添加一个类ExeceteOralceSqlHelper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
namespace asp.net_下拉树实现
{
public class ExeceteOralceSqlHelper
{
//从config中获取链接字符串
public static readonly string connstr = ConfigurationManager.ConnectionStrings["sqlconn"].ToString();
//获得connection对象
public static SqlConnection GetConn()
{
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
return conn;
}
//获得DataTable
public DataTable GetDataTable(string sqlstr)
{
SqlConnection conn = GetConn();
SqlCommand cmd = new SqlCommand(sqlstr, conn);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataTable tb =