Example #1
0
        private void TreeSubGet(FineUIPro.TreeNodeCollection TreeNodes, DataRow Menu)
        {
            string    MenuSqlSub = SqlTree.Replace("@CODE", Menu["code"].ToString());
            DataTable dtMenu     = DbHelperOra.Query(MenuSqlSub).Tables[0];

            foreach (DataRow dr in dtMenu.Rows)
            {
                FineUIPro.TreeNode node = new FineUIPro.TreeNode();
                node.Text             = dr["name"].ToString();
                node.NodeID           = dr["code"].ToString();
                node.EnableClickEvent = true;

                TreeNodes.Add(node);
                TreeSubGet(node.Nodes, dr);
            }
        }
Example #2
0
        /// <summary>
        /// 生成菜单树
        /// </summary>
        /// <param name="menus"></param>
        /// <param name="parentMenuId"></param>
        /// <param name="nodes"></param>
        private int ResolveMenuTree(List <Menu> menus, Menu parentMenu, FineUIPro.TreeNodeCollection nodes)
        {
            int count = 0;

            foreach (var menu in menus.Where(m => m.Parent == parentMenu))
            {
                FineUIPro.TreeNode node = new FineUIPro.TreeNode();
                nodes.Add(node);
                count++;

                node.Text    = menu.Name;
                node.IconUrl = menu.ImageUrl;
                if (!String.IsNullOrEmpty(menu.NavigateUrl))
                {
                    node.EnableClickEvent = false;
                    node.NavigateUrl      = ResolveUrl(menu.NavigateUrl);
                    //node.OnClientClick = String.Format("addTab('{0}','{1}','{2}')", node.NodeID, ResolveUrl(menu.NavigateUrl), node.Text.Replace("'", ""));
                }

                if (menu.IsTreeLeaf)
                {
                    node.Leaf = true;

                    // 如果是叶子节点,但是不是超链接,则是空目录,删除
                    if (String.IsNullOrEmpty(menu.NavigateUrl))
                    {
                        nodes.Remove(node);
                        count--;
                    }
                }
                else
                {
                    //node.SingleClickExpand = true;

                    int childCount = ResolveMenuTree(menus, menu, node.Nodes);

                    // 如果是目录,但是计算的子节点数为0,可能目录里面的都是空目录,则要删除此父目录
                    if (childCount == 0 && String.IsNullOrEmpty(menu.NavigateUrl))
                    {
                        nodes.Remove(node);
                        count--;
                    }
                }
            }

            return(count);
        }