private void GetMenuTree(List<Models.POCO.TreeNode> tree, List<SysMenu> menus, long parent, long? checkedmenu)
        {
            var submenus = menus.Where(x => x.Parent == parent && x.ID != parent);
            foreach (var menu in submenus)
            {
                var menunode = new Models.POCO.TreeNode();
                menunode.id = menu.ID;
                menunode.text = menu.Name;

                if (menu.ID == checkedmenu)
                {
                    menunode.@checked = true;
                }

                menunode.children = new List<Models.POCO.TreeNode>();

                //递归加载子节点
                GetMenuTree(menunode.children, menus, menu.ID, checkedmenu);

                if (menunode.children.Count > 0)
                {
                    menunode.state = "closed";
                }
                tree.Add(menunode);
            }
        }
示例#2
0
        private void GetMenuTree(List <Models.POCO.TreeNode> tree, List <SysMenu> menus, long parent, long?checkedmenu)
        {
            var submenus = menus.Where(x => x.Parent == parent && x.ID != parent);

            foreach (var menu in submenus)
            {
                var menunode = new Models.POCO.TreeNode();
                menunode.id   = menu.ID;
                menunode.text = menu.Name;

                if (menu.ID == checkedmenu)
                {
                    menunode.@checked = true;
                }

                menunode.children = new List <Models.POCO.TreeNode>();

                //递归加载子节点
                GetMenuTree(menunode.children, menus, menu.ID, checkedmenu);

                if (menunode.children.Count > 0)
                {
                    menunode.state = "closed";
                }
                tree.Add(menunode);
            }
        }