Пример #1
0
        public JsonResult GetTreeJson()
        {
            List <FuncMgrModel> funcMenu = new List <FuncMgrModel>();

            FuncMgrModel rootItem = new FuncMgrModel();

            rootItem.nodeId = 0;
            rootItem.text   = "根節點";
            funcMenu.Add(rootItem);

            var nodes = ChildrenOf(rootItem);

            return(Json(nodes, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public static FuncMgrModel ChildrenOf(FuncMgrModel func)
        {
            CodeFuncDao codeFunctionDao = new CodeFuncDao();

            List <CODE_FUNC> funcList = codeFunctionDao.qryDetail();

            foreach (CODE_FUNC child in funcList.Where(x => Convert.ToInt64(x.PARENT_FUNC_ID.Trim()) == func.nodeId).OrderBy(x => x.FUNC_ORDER))
            {
                FuncMgrModel item = new FuncMgrModel();
                item.Id       = child.FUNC_ID;
                item.nodeId   = Convert.ToInt32(child.FUNC_ID);
                item.parentId = Convert.ToInt32(child.PARENT_FUNC_ID);
                item.text     = child.FUNC_NAME.Trim();

                if (child.FUNC_LEVEL == 2)
                {
                    item.nodes = null;
                }

                func.nodes.Add(ChildrenOf(item));
            }

            return(func);
        }