示例#1
0
 public ActionResult GetTreeTest()
 {
     List<Sys_Dept> list = new Sys_DeptDAL().GetList();
     List<TreeObj> listObj = new List<TreeObj>();
     TreeObj modelRoot = new TreeObj();
     modelRoot.id = 0;
     modelRoot.pId = -1;
     modelRoot.name = "Root";
     modelRoot.open = true;
     listObj.Add(modelRoot);
     if (list != null && list.Count > 0)
     {
         foreach (var item in list)
         {
             TreeObj model = new TreeObj();
             model.id = item.Id;
             model.pId = item.ParentId;
             model.name = item.DeptName;
             model.open = true;
             listObj.Add(model);
         }
     }
     return Json(listObj, JsonRequestBehavior.AllowGet);
 }
示例#2
0
 public ActionResult GetTreeTest()
 {
     List<Sys_Template> list = new Sys_TemplateDAL().GetList();
     List<TreeObj> listObj = new List<TreeObj>();
     TreeObj rootObj = new TreeObj();
     rootObj.id = 0;
     rootObj.name = "Root";
     rootObj.pId = 100000;
     listObj.Add(rootObj);
     if (list != null && list.Count > 0)
     {
         foreach (var item in list)
         {
             TreeObj model = new TreeObj();
             model.id = item.Id;
             model.pId = item.ParentId;
             model.name = item.Template;
             model.obj1 = item.TemplateUrl;
             model.obj2 = item.Lever.ToString();
             listObj.Add(model);
         }
     }
     return Json(listObj, JsonRequestBehavior.AllowGet);
 }