zTree5
//DfxRepository.cs #region 获取类别树 public string BuildCategoryTreeChildNode(string id, string pduid, string pduaddress, string selecttreeid) { List nodeList = new List(); List expandidList = new List(); List allList = catedb.MANAGER_CFG_CATEGORY.ToList(); nodeList = GetCategoryChildNodes(ref allList, ref nodeList, int.Parse(id), expandidList, pduid); return JsonDataConverter.Serialize(nodeList.ToArray()); } public List GetCategoryChildNodes(ref List allList, ref List nodeList, int id, List expandidList, string pduid) { List list = new List(); List childList = new List(); //list = allList.Where(x => x.ParentId == id && x.PduId == Convert.ToInt32(pduid)).OrderByDescending(x => x.CateOrder).OrderByDescending(x => x.Id).ToList(); list = (from x in allList where x.ParentId == id && x.PduId == Convert.ToInt32(pduid) orderby x.CateOrder, x.Id select x).ToList(); foreach (var item in list) { ProductTreeClass node = new ProductTreeClass(); node.id = item.Id.ToString(); node.name = item.CateName; node.isParent = false; node.open = true; node.url = "../Menu/CategoryMenu?treeid=" + item.Id + "&treename=" + item.CateName + "&typename="+item.TypeName+""; node.target = "mv"; //判断是否有子节点 if (allList.Where(x => x.ParentId == item.Id).Count() > 0) { node.isParent = true; } node.nodes = GetCategoryChildNodes(ref allList, ref childList, item.Id, expandidList, pduid); childList.Add(node); } return childList; } #endregion public class ProductTreeClass { public string id {get; set;} public string name {get; set;} public string url {get; set;} public bool isParent {get; set;} public bool open {get; set;} public List nodes {get; set;} public string userData {get; set;} public string target { get; set; } }