Esempio n. 1
0
        public static List <TreeNodeForJsTree> GetTreeNodes(List <SelfReferentialItem> sourceItems)
        {
            var treeViewItems = new List <TreeNodeForJsTree>();

            foreach (var item in sourceItems)
            {
                var node = new TreeNodeForJsTree
                {
                    Id   = item.ID,
                    Text = item.DisplayName
                };

                if (item.ID == item.ParentID)
                {
                    node.Parent = "#";
                }
                else
                {
                    node.Parent = item.ParentID;
                }

                treeViewItems.Add(node);
            }
            return(treeViewItems);
        }
Esempio n. 2
0
        public static TreeNodeForJsTree GetTreeRootNode(string id, string nodeText)
        {
            var node = new TreeNodeForJsTree();

            node.Parent = "#";
            node.Text   = nodeText;
            node.Icon   = "far fa-edits";
            return(node);
        }
Esempio n. 3
0
        public static TreeNodeForJsTree GetTreeRootNode(string id, SelfReferentialItem selfReferentialItem)
        {
            var node = new TreeNodeForJsTree();

            node.Id     = id;
            node.Parent = "#";
            node.Text   = selfReferentialItem.DisplayName;
            node.Icon   = "far fa-edit";
            return(node);
        }
Esempio n. 4
0
        /// <summary>
        /// 递归处理
        /// </summary>
        /// <param name="rootTreeNode"></param>
        /// <param name="rootSourceNode"></param>
        /// <param name="sourceItems"></param>
        private static void _GetSubNodes(TreeNodeForJsTree rootTreeNode, SelfReferentialItem rootSourceNode, List <SelfReferentialItem> sourceItems)
        {
            var subItems = sourceItems.Where(sn => sn.ParentID == rootSourceNode.ID && sn.ID != rootSourceNode.ParentID).OrderBy(o => o.SortCode);

            foreach (var item in subItems)
            {
                var treeNode = _GetSubTreeNode(item);
                rootTreeNode.Nodes.Add(treeNode);
                _GetSubNodes(treeNode, item, sourceItems);
            }
        }
Esempio n. 5
0
        private static TreeNodeForJsTree _GetSubTreeNode(SelfReferentialItem selfReferentialItem)
        {
            var node = new TreeNodeForJsTree
            {
                Id     = selfReferentialItem.ID,
                Parent = "#",
                Text   = selfReferentialItem.DisplayName,
                Icon   = "glyphicons glyphicons-folder-minus"
            };

            return(node);
        }