/// <summary>
 /// Jquery树
 /// </summary>
 /// <param name="val"></param>
 /// <param name="NameCn"></param>
 /// <returns></returns>
 public static string JqTreeNs_Pre_OrganizationID(string val, string NameCn, SoftProjectAreaEntity item)
 {
     List<SoftProjectAreaEntity> Items = SoftProjectAreaEntityDomain.Pre_Organizations.Where(p => p.LoginCategoryID == item.LoginCategoryID).ToList();
     var treeList = new TreeList(Items, "0", "OrganizationName", "Pre_OrganizationID", "ParentPre_OrganizationID", "", "", "Pre_OrganizationID", "", "");
     var str = HtmlHelpersProject.JqTreeN(null, "Pre_OrganizationID", treeList, "", 2);
     return str.ToString();
 }
 /// <summary>
 /// Jquery树
 /// </summary>
 /// <param name="val"></param>
 /// <param name="NameCn"></param>
 /// <returns></returns>
 public static string JqTreeNs_T_ToolCategoryID(string val, string NameCn, SoftProjectAreaEntity item)
 {
     var Pre_Company = HttpContext.Current.Session["LoginInfo"] as SoftProjectAreaEntity;
     var Itemst = SoftProjectAreaEntityDomain.T_ToolCategorys.Where(p => p.Pre_CompanyID == Pre_Company.CompanyID);
     //var Itemst = SoftProjectAreaEntityDomain.T_ToolCategorys;
         var treeList = new TreeList(Itemst, "0", "ToolCategoryName", "T_ToolCategoryID", "ParentT_ToolCategoryID", "", "", "T_ToolCategoryID", "", "");
         var str = HtmlHelpersProject.JqTreeN(null, "T_ToolCategoryID", treeList, "", 2);
         return str.ToString();
 }
        //@Html.JqTree("OrganizationsTree", ViewData["ListOrganizationsTree"] as TreeList, ViewData["currentPath"].ToString(), false)

        public static MvcHtmlString JqTreeN(this HtmlHelper helper, string ID, TreeList treeList, string selectTreeNode, int? paramNameType = 1, bool parentLink = true, bool bcontroll = false)
        {
            string urlpath = HttpContext.Current.Request.Url.AbsolutePath;
            //var urlpathcount = urlpath.Split('/').Count();
            //if (urlpathcount > 3)
            //{
            //    var pos=urlpath.LastIndexOf("/");
            //    urlpath = urlpath.Substring(0, pos);
            //}
            //urlpath += "/IndexTree";
            string PKField = treeList.ValueField;
            string ParentField = treeList.ParentField;//	"ParentCaseCategoryID"	string
            if (paramNameType == 1)
                ParentField = PKField;


            List<TreeNode> treeNodes = treeList.TreeNodes;
            StringBuilder sb = new StringBuilder("<div id='" + ID + "' class='my-tree-menu'>");
            sb.AppendLine("<ul>");
            var root = new List<TreeNode>();
            if (treeList.RootValue == null)
                root = treeList.TreeNodes.Where(p => p.ParentTreeNodeID == null).ToList();
            else
                root = treeList.TreeNodes.Where(p => p.ParentTreeNodeID == treeList.RootValue).ToList();
            var count = root.Count();
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    List<TreeNode> Sublist = treeNodes.Where(p => p.ParentTreeNodeID == root[i].TreeNodeID).ToList();//.ModularFuns.ToList();
                    int SubCount = Sublist.Count();

                    if (SubCount > 0)//非叶节点
                    {
                        var icon = "glyphicon-folder-close";
                        var selectIselected = "";
                        var bopen = false;
                        if (selectTreeNode.Contains(treeList.RootValue + "/" + root[i].Value + "/"))
                        {
                            selectIselected = " class='selected' ";
                            icon = "glyphicon-folder-open";
                            bopen = true;
                        }
                        var liclass = "";
                        if (selectTreeNode == treeList.RootValue + "/" + root[i].Value + "/")
                            liclass = "active";

                        sb.AppendLine("<li class=''>");
                        //sb.AppendLine(string.Format("<a " + selectIselected + " href='{0}?IsFinalLevel=1&{1}={2}&currentPath={3}'><i class='glyphicon " + icon + "'></i>{4}</a>", urlpath + treeList.ControllerAction, "Item." + PKField, root[i].Value, treeList.RootValue + "/" + root[i].TreeNodeID + "/", root[i].Text));
                        sb.AppendLine(string.Format("<a class='selected btn-FwBtnSubmit' data-fun='2' " + selectIselected + " href='javascript:void(0);' data-posturl='{0}?Querys[0].FieldName={1}___equal&Querys[0].Value={2}'><i class='glyphicon glyphicon-folder-close'></i>{3}</a>", urlpath, ParentField, root[i].Value, root[i].Text));

                        sb.AppendLine(JqBindTreeN(root[i], treeNodes, treeList.ControllerAction, treeList.RootValue + "/" + root[i].TreeNodeID + "/", ParentField, selectTreeNode, 1, parentLink, i == count - 1, urlpath, bopen));
                        sb.AppendLine("</li>");
                    }
                    else//叶子节点
                    {
                        var selectIselected = "";
                        var liclass = "";
                        if (selectTreeNode == treeList.RootValue + "/" + root[i].Value + "/")
                        {
                            selectIselected = " class='selected' ";
                            liclass = "active";
                        }
                        //sb.AppendLine(string.Format("<li class='" + liclass + "'><a " + selectIselected + " href='{0}?IsFinalLevel=0&{1}={2}&currentPath={3}'>{4}</a></li>", urlpath + "/" + treeList.ControllerAction, "Item." + PKField, root[i].Value, treeList.RootValue + "/" + root[i].TreeNodeID + "/", root[i].Text));
                        sb.AppendLine(string.Format("<li class='" + liclass + "'>"));
                        sb.AppendLine(string.Format("<a class='btn-FwBtnSubmit' data-fun='2' " + selectIselected + " href='javascript:void(0);' data-posturl='{0}?Querys[0].FieldName={1}___equal&Querys[0].Value={2}'>{3}</a>", urlpath, ParentField, root[i].Value, root[i].Text));
                        sb.AppendLine("</li>");
                    }
                }
            }

            sb.AppendLine("</ul></div>");
            MvcHtmlString mstr = new MvcHtmlString(sb.ToString());
            return mstr;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Jquery树
        /// </summary>
        /// <param name="val"></param>
        /// <param name="NameCn"></param>
        /// <returns></returns>
        public static string JqTreeNs_P_CategoryID(string paramNameType, string NameCn, SoftProjectAreaEntity item)
        {
            var TreeQueryType = Convert.ToInt32(paramNameType);
            //var Pre_Company = HttpContext.Current.Session["LoginInfo"] as SoftProjectAreaEntity;
            //var Itemst = SoftProjectAreaEntityDomain.P_Categorys.Where(p => p.Pre_CompanyID == Pre_Company.CompanyID);
            var Itemst = SoftProjectAreaEntityDomain.P_Categorys;
            var treeList = new TreeList(Itemst, "0", "PCategoryName", "P_CategoryID", "ParentP_CategoryID", "", "", "P_CategoryID", "", "");
            var str = HtmlHelpersProject.JqTreeN(null, "P_CategoryID", treeList, "", TreeQueryType);
            return str.ToString();

            //var Itemst = ProjectCache.P_Categorys;
            //var treeList = new TreeList(Itemst, "0", "PCategoryName", "P_ProductCategoryID", "ParentProductCategoryID", "", "", "P_ProductCategoryID", "", "");
            //    var str = JqTreeN(helper, ID, treeList, "", paramNameType);
            //    return str;
        }