Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • MK 426 posts 902 karma points
    Apr 07, 2012 @ 18:24
    MK
    0

    Get all nodes under root

     

    Hi there,

    Does anyone know can I get all the nodes under the root node?

    Cheers

    mkariti

     

  • MK 426 posts 902 karma points
    Apr 07, 2012 @ 19:20
    MK
    0

    C# ofcourse

  • MK 426 posts 902 karma points
    Apr 08, 2012 @ 10:36
    MK
    0

    Hi there,

    Will it be ok to use:

          umbraco.presentation.nodeFactory.Node node = new umbraco.presentation.nodeFactory.Node(1122);
                var all = node.AllDescendants();

    This is a obsolete class.

    cheers

    mkariti

  • MK 426 posts 902 karma points
    Apr 08, 2012 @ 12:36
    MK
    0

    Ok So I decided to use the recursive option and added Jquery to it.

    Here is my code:

    private void LoadData()
            {
                Node rootNode = new Node(1122);
                StringBuilder sb = new StringBuilder();
                sb.Append("<ul id='example'>");
                DoIt(rootNode, sb);
                sb.Append("</ul>");
                Panel1.Controls.Add(new LiteralControl(sb.ToString()));
    
            }
            private void DoIt(Node node, StringBuilder sb)
            {
    
                foreach (Node ChildNode in node.Children)
                {
                    string strChecked = "";
                    sb.Append("<li>");
                    if (CategoryManager.HasRelation(this.CurrentMemebrID, ChildNode.Id))
                        strChecked = "checked='checked'";
                    else
                        strChecked = "";
                    sb.Append("<input type='checkbox' value='" + ChildNode.Id + "'" + strChecked + " name='CategoryTree' id='" + ChildNode.Id + "'>");
                    sb.Append(ChildNode.Name);
    
                    if (ChildNode.Children.Count > 0)
                    {
                        sb.Append("<ul>");
                        DoIt(ChildNode, sb);
                        sb.Append("</ul>");
                    }
    
                    sb.Append("</li>");
                }
            }
    
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies