Exemplo n.º 1
0
        /// <summary>
        /// 获取树形展示数据
        /// </summary>
        /// <returns></returns>
        public ActionResult GetTreeJson()
        {
            List <TreeData>     treeList = new List <TreeData>();
            List <DictTypeInfo> typeList = BLLFactory <DictType> .Instance.Find("PID='-1' ");

            foreach (DictTypeInfo info in typeList)
            {
                TreeData node = new TreeData(info.ID, info.PID, info.Name);
                GetTreeJson(info.ID, node);

                treeList.Add(node);
            }
            return(ToJsonContent(treeList));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 递归获取树形信息
        /// </summary>
        /// <returns></returns>
        private void GetTreeJson(string PID, TreeData treeNode)
        {
            string condition             = string.Format("PID='{0}' ", PID);
            List <DictTypeInfo> nodeList = BLLFactory <DictType> .Instance.Find(condition);

            StringBuilder content = new StringBuilder();

            foreach (DictTypeInfo model in nodeList)
            {
                TreeData node = new TreeData(model.ID, model.PID, model.Name);
                treeNode.children.Add(node);

                GetTreeJson(model.ID, node);
            }
        }