码迷,mamicode.com
首页 > 其他好文 > 详细

Tree数据格式 Easyui

时间:2017-05-25 01:18:58      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:ict   wget   open   request   htm   ble   idt   str   state   

public ActionResult GetTreeJson()

        {

            List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();

            var list = bpDAL.GetList(o => o.Tree.ParentId == 0).ToList();

            int count = list.Count();

            for (int i = 0; i < count; i++)

            {

                Dictionary<string, object> row = new Dictionary<string, object>();

                row.Add("id", list[i].Id);

                row.Add("text", list[i].PowerName);

                row.Add("state", list[i].Tree.IsLeaf == false ? "closed" : "open");

                row.Add("children", GetTreeChildrenJson(list[i].Id));

                rows.Add(row);

            }

            return Json(rows, "text/html", JsonRequestBehavior.AllowGet);

 

        }

 

        public List<Dictionary<string, object>> GetTreeChildrenJson(int Id)

        {

            List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();

            var list = bpDAL.GetList(o => o.Tree.ParentId == Id).ToList();

            int count = list.Count();

            for (int i = 0; i < count; i++)

            {

                Dictionary<string, object> row = new Dictionary<string, object>();

                if (list[i].Tree.IsLeaf == false)

                {

                    row.Add("id", list[i].Id);

                    row.Add("text", list[i].PowerName);

                    row.Add("state", list[i].Tree.IsLeaf == false ? "closed" : "open");

                    row.Add("children", GetTreeChildrenJson(list[i].Id));

                    rows.Add(row);

                }

                else

                {

                    row.Add("id", list[i].Id);

                    row.Add("text", list[i].PowerName);

                    row.Add("state", list[i].Tree.IsLeaf == false ? "closed" : "open");

                    rows.Add(row);

                }

            }

            return rows;

        }

Tree数据格式 Easyui

标签:ict   wget   open   request   htm   ble   idt   str   state   

原文地址:http://www.cnblogs.com/duanyuerui/p/6901648.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!