TreeList节点展开与收缩

介于树节点的展开与收缩是经常多处使用的,这里就写个两个调用方法。

TreeList节点展开与收缩
        /// <summary>
        /// 展开指定节点以及其父节点
        /// </summary>
        /// <param name="tree">树</param>
        /// <param name="appointNode">要展开的节点</param>
        public static void ExpandAppointTreeNode(this TreeList tree, TreeListNode appointNode)
        {
            tree.Nodes.TreeList.FindNodeByID(appointNode.Id).Expanded = true;
            while (appointNode.ParentNode != null)
            {
                tree.Nodes.TreeList.FindNodeByID(appointNode.ParentNode.Id).Expanded = true;
                appointNode = appointNode.ParentNode;
            }
        }
        /// <summary>
        /// 收缩指定节点
        /// </summary>
        /// <param name="tree">树</param>
        /// <param name="appointNode">要收缩的节点</param>
        public static void ShrinkAppointTreeNode(this TreeList tree, TreeListNode appointNode)
        {
            tree.Nodes.TreeList.FindNodeByID(appointNode.Id).Expanded = false;
        }
View Code

 

上一篇:js 实现二叉树的前序, 中序, 后序遍历


下一篇:element中的el-form踩的坑