easyui treeJson 带层数

easyui treeJson 带层数
public string GetTreeNav(int ID,int Num)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("[{\"id\":1,\"text\":\"根目录\",\"children\":[");
            sb.Append(GetTreeSon(ID,Num));
            sb.Append("]}]");
            return sb.ToString();
        }
        public string GetTreeSon(int ID,int Num)
        {
            StringBuilder sb = new StringBuilder();
            DataTable dt = GetTableByParentID(ID,"视频");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (Num == 1) { sb.Append("{\"id\":" + dt.Rows[i]["ID"].ToString() + ",\"text\":\"" + dt.Rows[i]["ClassName"].ToString() + "\"}"); }
                else {
                    sb.Append("{\"id\":" + dt.Rows[i]["ID"].ToString() + ",\"text\":\"" + dt.Rows[i]["ClassName"].ToString() + "\",\"state\":\"closed\",\"children\":[" + GetTreeSon(Convert.ToInt32(dt.Rows[i]["ID"]), Num - 1) + "]}");
                }
                if (i < dt.Rows.Count - 1)
                {
                    sb.Append(",");
                }
            }
            return sb.ToString();
        }
easyui treeJson 带层数

easyui treeJson 带层数,布布扣,bubuko.com

easyui treeJson 带层数

上一篇:jquery 事件绑定(1)


下一篇:MVVM架构~knockoutjs系列之验证信息自定义输出~再续