public StringBuilder GetPostTreeStr(int flag, string type, string clickFunction) { string prefix = ""; if (type == "checkbox") { prefix = "<input type='checkbox' class='fll' id='{0}' value='{4}' />"; } else if (type == "radio") { prefix = "<input type='radio' class='fll' id='{0}' value='{4}' name='prd'/>"; } var treeStr = new StringBuilder(); if (flag == 0) { treeStr.AppendFormat( "<ul id=\"navigation\" class=\"treeview\"><li id=\"0\"><span title='{2}' id='{1}' class=\"rootNote\">{2}</span><ul>", 0, "0_-1", CommonLanguage.ParentPost, "", "0_-1_" + CommonLanguage.ParentPost); } else { treeStr.AppendLine("<ul id=\"navigation\" class=\"treeview\">"); } GetPostTreeChild(AllPosts.FindAll(p => p.ParentId == 0), treeStr, clickFunction, prefix); if (flag == 0) { treeStr.AppendLine("</ul></li></ul>"); } else { treeStr.AppendLine("</ul>"); } return(treeStr); }
private void GetPostTreeChild(List <Sys_Post> postList, StringBuilder html, string clickFunction = "postNodeClick(this)", string prefix = "") { if (postList.Count > 0) { foreach (Sys_Post v in postList) { //string post = v.PostCode + "[" + v.PostName + "]"; string post = v.PostName; html.AppendFormat( "<li class='treeChild'>" + prefix + "<a title='{2}' style='cursor:pointer;' class='pNote' id='{1}' {3} >{2}</a>", v.PostId, v.PostId + "_" + v.ParentId, post, (string.IsNullOrWhiteSpace(clickFunction) ? "" : "onclick=\"" + clickFunction + "\""), v.PostId + "_" + v.ParentId + "_" + post); if (AllPosts.Exists(p => p.ParentId == v.PostId)) { html.AppendLine("<ul>"); GetPostTreeChild(AllPosts.FindAll(p => p.ParentId == v.PostId), html, clickFunction, prefix); html.AppendLine("</ul>"); } html.AppendLine("</li>"); } } }
private void DeletePostChild(int postId) { postBL.Delete(postId); AllPosts.Remove(AllPosts.Find(p => p.PostId == postId)); if (AllPosts.FindAll(p => p.ParentId == postId).Count > 0) { foreach (Sys_Post item in AllPosts.FindAll(p => p.ParentId == postId)) { DeletePostChild(item.PostId); } } }