当前位置: 首页>>代码示例>>C#>>正文


C# Tree.GetTreeNodeChild方法代码示例

本文整理汇总了C#中Tree.GetTreeNodeChild方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.GetTreeNodeChild方法的具体用法?C# Tree.GetTreeNodeChild怎么用?C# Tree.GetTreeNodeChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


在下文中一共展示了Tree.GetTreeNodeChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OperateTreeNode

 //// NodeId: id, NodeInfo: nodeInfo, XmlUrl: temp.xmlUrl 
 public ActionResult OperateTreeNode(string modeType, string _modeType, string nodeId, string nodeInfo, string xmlUrl)
 {
     using (RRDLEntities db = new RRDLEntities())
     {
         Tree tree = new Tree();
         TreeNode treeNode = null;
         switch (modeType)
         {
             case "rename":
                 string id = nodeId;
                 string name = nodeInfo;
                 treeNode = tree.GetTreeNodeById(Int32.Parse(id));
                 treeNode.Title = name;
                 tree.UpdateTreeNode(treeNode);
                 returnStr = "ok&" + treeNode.ParentId;
                 break;
             case "delete":
                 returnStr = DeleteNode(_modeType, nodeId, xmlUrl);                        
                 break;
             case "insert":
                 //List<NodeInfo> nodeList = this.GetListFromJson(nodeInfo);
                 //returnStr = this.InserNode(_modeType, nodeId, xmlUrl, nodeList);
                 //bool flag = true;
                 Tree tree2 = new Tree(db);
                 List<TreeNode> list = tree2.GetTreeNodeChild(Int32.Parse(nodeId));
                 //for (int i = 0; i < list.Count;i++ )
                 //{
                 //    if(list[i].Ariticle != null){
                 //        flag = false; 
                 //    }
                 //}
                 //if (flag)
                 //{
                     treeNode = new TreeNode(Int32.Parse(nodeId), "新建节点");
                     tree.AddTreeNode(treeNode);
                     returnStr = "ok";
                 //}
                 //else {
                 //    returnStr = "该节点下存在文章,不能添加文件夹!";
                 //}
                 break;
         }
         return Content(returnStr);
     }
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:46,代码来源:TreeViewController.cs

示例2: DeleteNode

 //The Function Bllew is Added By ZHAOs ,2013年11月14日10:02:13,used to Delete A TreeNode in 目录树管理
 public string DeleteNode(string _modeType, string nodeId, string xmlUrl) {
     // _modeType = "deleteFolder"  ,modeId = "6" ,xmlUrl = ""  传入的参数大致形式如此
     Tree tree = new Tree();
     TreeNode treeNode = tree.GetTreeNodeById(Convert.ToInt32(nodeId));
     string returnStr = "";
     /*
     如果这个节点是叶子节点
         如果是空文件夹  --文件夹(ariticleID为空且isLeaf属性为True),为空文件夹 ===> 可删除
         如果是知识   --不能删除知识  (此时 ariticleID属性不为NULL  且 idLeaf属性为 True即是)
     如果这个节点不是叶子节点(即非空文件夹,里面可能有知识或者 为空不为空的 文件夹)(ariticleID为空且isLeaf属性为false)====> 不能删除
     PS:但是这里不显示知识,所以只可能有 叶子节点文件夹 和 非叶子节点文件夹。
      * 叶子节点文件夹内部一定没有知识,可以直接删除 ===>有知识的情况 以后版本考虑
      * 非叶子节点文件夹内容一定有文件夹或知识,不能删除。
      * 逻辑较简单。
      * 只是只能从叶子节点删起      
      * PS:如果一个父节点其下的所有子节点都被删除,则该父节点的IsLeaf属性变为True
      */
     if (treeNode.IsLeaf == true)
     {   
         //如果是根目录
         if (treeNode.ParentId == null)
         {
             returnStr = "根目录不可删除!";
         }
         else {//若果其父节点下只有这一个子节点,则删除此子节点并把父节点isLeaf属性设为True
             TreeNode parentNode = tree.GetTreeNodeById(Convert.ToInt32(treeNode.ParentId));
             List<TreeNode> parentChildList = tree.GetTreeNodeChild(Convert.ToInt32(treeNode.ParentId));
             if (parentChildList.Count == 1)
             {
                 parentNode.IsLeaf = true;
             }
             tree.UpdateTreeNode(parentNode);//改变父节点isLeaf属性
             tree.Drop(treeNode);//删除子节点
             returnStr = "ok";
         }
         
     }
     else {
         returnStr = "该节点下存在子文件夹或知识,不能删除!";
     }
     return returnStr;
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:43,代码来源:TreeViewController.cs

示例3: GetTreeByRootIdForTreeManage

        public ActionResult GetTreeByRootIdForTreeManage(string nodeId, string treeName)
        {
            using (RRDLEntities db = new RRDLEntities())
            {
                Tree tree = new Tree(db);
                TreeNode rootNode = tree.GetRootNode(treeName);
                string result = "";
                if (nodeId != "")
                {
                    int rootId = Int32.Parse(nodeId);
                    List<TreeNode> list = tree.GetTreeNodeChild(rootId);
                    TreeViewModel tvm = new TreeViewModel();
                    List<TreeViewModel> tlist = new List<TreeViewModel>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i].Ariticle == null)
                        {
                            tvm = new TreeViewModel();
                            tvm.Deepth = list[i].Deepth;
                            tvm.Id = list[i].Id;
                            tvm.IsLeaf = false;
                            tvm.ParentId = list[i].ParentId;
                            tvm.Title = list[i].Title;
                            tlist.Add(tvm);
                        }
                    }
                    result = JsonConvert.SerializeObject(tlist);
                }
                else
                {
                    result = "[{\"Ariticle\":\"null\",\"Id\":\"" + rootNode.Id + "\",\"Title\":\"" + rootNode.Title + "\",\"Deepth\":\"" + rootNode.Deepth + "\",\"ParentId\":\"null\",\"IsLeaf\":\"" + rootNode.IsLeaf + "\"}]";
                }

                // List<TreeNode>

                return Content(result);
            }
        }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:38,代码来源:TreeViewController.cs

示例4: isAdd

 //判断选择节点是否正确
 public string isAdd(string treeNode) {
     using (RRDLEntities db = new RRDLEntities())
     {
         Tree tree = new Tree(db);
         List<TreeNode> list = tree.GetTreeNodeChild(Int32.Parse(treeNode));
         string flag = "";
         if (list.Count > 0)
         {
             if (list[0].Ariticle != null)
             {
                 flag = "true";
             }
         }
         else {
             flag = "true";
         }
         return flag;
     }
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:20,代码来源:TreeViewController.cs

示例5: ReadTreeNodes

 public List<ClassifyTreeNodes> ReadTreeNodes(List<ClassifyTreeNodes> treeNodes, int? id)
 {
     Tree tree = new Tree();
     List<TreeNode> newTreeNodes = tree.GetParentsTreeNodes(id);
     List<ClassifyTreeNodes> treeNodeLists = new List<ClassifyTreeNodes>();
     for (int i = 0; i < newTreeNodes.Count; i++)
     {
         ClassifyTreeNodes treeNode = new ClassifyTreeNodes();
         treeNode.Title = newTreeNodes[i].Title;
         //treeNode.AriticleId = newTreeNodes[i].Ariticle.Id;
         
         treeNode.Id = newTreeNodes[i].Id;
         treeNode.ParentId = newTreeNodes[i].ParentId;
         treeNode.IsLeaf = newTreeNodes[i].IsLeaf;
         if (treeNode.ParentId == null) {
             treeNodes.Add(treeNode);
             treeNodeLists.Add(treeNode);
         }
         //if (treeNode.IsLeaf == false)
         //{
         //    ReadTreeNodes(treeNodes, treeNode.Id);
         //}
     }
     for (int j = 0; j < treeNodes.Count; j++)
     {
          List<TreeNode> tns = new List<TreeNode>();
          tns = tree.GetTreeNodeChild(Int32.Parse(treeNodes[j].Id.ToString()));
          for (int k = 0; k < tns.Count; k++) {
              TreeNode treeNode = tree.GetTreeNodeById(Int32.Parse(tns[k].Id.ToString()));
              ClassifyTreeNodes classifyTreeNodes = new ClassifyTreeNodes();
              classifyTreeNodes.Id = treeNode.Id;
              classifyTreeNodes.IsLeaf = treeNode.IsLeaf;
              classifyTreeNodes.ParentId = treeNode.ParentId;
              classifyTreeNodes.Title = treeNode.Title;
              treeNodeLists.Add(classifyTreeNodes);
          }
     }
     return treeNodeLists;
 }
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:39,代码来源:RankListController.cs


注:本文中的Tree.GetTreeNodeChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。