/// <summary>获取异步生成的树</summary> /// <param name="treeName">树</param> /// <param name="parentId">父级节点标识</param> /// <param name="url">链接地址</param> /// <param name="enabledLeafClick">只允许点击叶子节点</param> /// <param name="elevatedPrivileges">提升权限</param> /// <returns>布尔值</returns> public DynamicTreeView GetDynamicTreeView(string treeName, string parentId, string url, bool enabledLeafClick, bool elevatedPrivileges) { string searchPath = (parentId == "0") ? string.Empty : parentId.Replace(@"$", @"\"); IList <DynamicTreeNode> list = this.provider.GetDynamicTreeNodes(searchPath, string.Empty); DynamicTreeView treeView = new DynamicTreeView(treeName, parentId); Dictionary <string, DynamicTreeNode> dictionary = new Dictionary <string, DynamicTreeNode>(); foreach (DynamicTreeNode node in list) { node.ParentId = parentId; node.Url = url; if (!dictionary.ContainsKey(node.Id)) { if (node.HasChildren && enabledLeafClick) { node.Disabled = 1; } treeView.Add(node); dictionary.Add(node.Id, node); } } return(treeView); }
/// <summary>获取异步生成的树</summary> /// <param name="treeName">树</param> /// <param name="parentId">父级节点标识</param> /// <param name="url">链接地址</param> /// <param name="enabledLeafClick">只允许点击叶子节点</param> /// <returns>树</returns> public DynamicTreeView GetDynamicTreeView(string treeName, string parentId, string url, bool enabledLeafClick) { string searchPath = (parentId == "0") ? string.Empty : parentId.Replace(@"$", @"\"); IList <RegionInfo> data = this.FindAll(); data = data.Where(x => x.ParentId == parentId).ToList(); IList <DynamicTreeNode> list = new List <DynamicTreeNode>(); // this.provider.GetDynamicTreeNodes(searchPath, string.Empty); foreach (RegionInfo d in data) { list.Add(new DynamicTreeNode() { Id = d.Id, Name = d.Name, ParentId = d.ParentId }); } DynamicTreeView treeView = new DynamicTreeView(treeName, parentId); Dictionary <string, DynamicTreeNode> dictionary = new Dictionary <string, DynamicTreeNode>(); foreach (DynamicTreeNode node in list) { node.ParentId = parentId; node.Url = url; if (!dictionary.ContainsKey(node.Id)) { if (node.HasChildren && enabledLeafClick) { node.Disabled = 1; } treeView.Add(node); dictionary.Add(node.Id, node); } } return(treeView); }