Copied to clipboard

Flag this post as spam?

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


  • Sa 118 posts 152 karma points
    Oct 27, 2009 @ 08:56
    Sa
    0

    Child nodes in custom Section

    public override void Render(ref XmlTree tree)
    {
    XmlTreeNode xNode = XmlTreeNode.Create(this);
    xNode.NodeID = "cpSettings";
    xNode.Text = "Instellingen";
    xNode.Action = "javascript:openUrl('/umbraco/settings/EditSettings.aspx');";
    xNode.Icon = "settingDataType.gif";
    xNode.OpenIcon = "settingDataType.gif";
    tree.Add(xNode);
    }



    Now I want to append an XmlTreeNode as a child to "Instellingen".

    any  pointers?

  • Richard Soeteman 3875 posts 12037 karma points MVP
    Oct 27, 2009 @ 10:30
    Richard Soeteman
    0

    Hi Sam,

    I've had the same issue for umbImport and took a look how umbraco rendered the subtree. It uses tree.aspx. Hereby the Code snippet I'm using in umbImport

    protected

     

    void RenderSubtree(XmlTree tree, string treeType, string nodeType, string text)

    {

     

    XmlTreeNode node = XmlTreeNode.Create(this);

    node.NodeID =

    "-1";

    node.Text = text;

    node.Icon =

    "folder.gif";

    node.OpenIcon =

    "folder_o.gif";

     

    //Specific for the child nodes

    node.Source =

    "tree.aspx?app=" + this.app + "&id=" + this.id + "&treeType=" + treeType + "&rnd=" + Guid.NewGuid();

    node.NodeType = nodeType;

     

     

    tree.treeCollection.Add( node);

    }

    Then you can call the method using

    RenderSubtree(tree,

    "treealias", "somenodetype", "Text");

    Do that after

    Make sure the alias is defined in the database. This is the same as you did when you configured the cpSettings tree. One thing, make sure that you set the TreeInitialize value in the umbracoApptree table for the record to false.

    Hope it  helps you,

    Richard

  • Sa 118 posts 152 karma points
    Oct 27, 2009 @ 11:48
    Sa
    0

    Thanks Mr.Richards.,

    if i can get the code snippet of this as i am getting an error when i try to use

    node.source= "tree.aspx?app=" + this.app + "&id=" + this.id + "&treeType=" + treeType + "&rnd=" + Guid.NewGuid(); ..

    when i set TreeInitialize=false, the tree is not loading.

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Oct 27, 2009 @ 11:52
  • Sa 118 posts 152 karma points
    Oct 27, 2009 @ 11:56
    Sa
    0

    thanks., in that i referred dictionaryItems..

    How did you implemented it

  • Sa 118 posts 152 karma points
    Oct 28, 2009 @ 05:41
    Sa
    0

    hello.,

    where to i have to pass this method?

    RenderSubtree(tree,"treealias", "somenodetype", "Text");

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Oct 28, 2009 @ 09:04
  • Richard Soeteman 3875 posts 12037 karma points MVP
    Oct 28, 2009 @ 09:12
    Richard Soeteman
    0

    put this after tree.treeCollection.Add( node);

    Also make sure you've configured the tree in the database

  • Sa 118 posts 152 karma points
    Oct 28, 2009 @ 12:55
    Sa
    0

    Folks.,

    i have tried.. it is not working for me..

    this is the example code

    public override void Render(ref XmlTree tree)
    {
    XmlTreeNode Node1 = XmlTreeNode.Create(this);
    Node1 .NodeID = "1";
    Node1 .Text = "custom1";
    Node1 .Action = "javascript:openUrl('/umbraco/settings/EditSettings.aspx');";
    Node1 .Icon = "folder.gif";
    Node1 .OpenIcon = "folder_o.gif";
    tree.Add(Node1 );
    XmlTreeNode Node2 = XmlTreeNode.Create(this);
    Node2 .NodeID = "1";
    Node2 .Text = "custom2";
    Node2 .Action = "javascript:openUrl('/umbraco/settings/EditSettings.aspx');";
    Node2 .Icon = "folder.gif";
    Node2 .OpenIcon = "folder_o.gif";
    tree.Add(Node2 );
    }

    here custom1 is a parent and custom2 should be child of custom1..

    -custom1

         --custom2

    if you can trace what the actual issue is?

     

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Oct 28, 2009 @ 13:43
    Jeroen Breuer
    0

    Looking at your code you are just putting 2 nodes under the root node and you don't create child nodes. You should use

    xNode.Source = this.GetTreeServiceUrl(id);

    Let me show you an example:

    This is the parent node (StartNodeID = -1):

    if

     

    (this.id == this.StartNodeID)

    {

    xNode =

    XmlTreeNode.Create(this);

    xNode.NodeID =

    "Node1";

    xNode.Text =

    "RootNode";

    xNode.Icon =

    "folder.gif";

    xNode.OpenIcon =

    "folder_o.gif";

    xNode.Source =

    this.GetTreeServiceUrl(2);

    tree.Add(xNode);

    }

    The child node loads by using:

    if

     

    (this.id == 2)

    {

    xNode =

    XmlTreeNode.Create(this);

    xNode.NodeID =

    "ChildNode1";

    xNode.Text =

    "ChildNode";

    xNode.Icon =

    "folder.gif";

    xNode.OpenIcon =

    "folder_o.gif";

    tree.Add(xNode);

    }

    When the custom section is loaded only the rootnode (Node1) is visible. When you expand the node the code is being called again but 'this.id' will be '2' because that's how it's set at 'xNode.Source = this.GetTreeServiceUrl(2);'. This time the childnode will be created.

  • Sa 118 posts 152 karma points
    Oct 28, 2009 @ 14:17
    Sa
    0

    if i give StartNodeID== -1 .,it is not working so i tried startnodeId==0..

    when i try to run as above code .,i am getting repeated nodes... i coudn't trace out the exact issue

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Oct 28, 2009 @ 14:49
    Jeroen Breuer
    0

    I couldn't completely understand your last message but did you solve your problem? If so you should mark a reply as the solution.

  • Sa 118 posts 152 karma points
    Oct 28, 2009 @ 14:51
    Sa
    0

    still i am getting repeated nodes

  • Sa 118 posts 152 karma points
    Oct 29, 2009 @ 06:30
    Sa
    0

    hello.,

    i am getting infinite repeated nodes..

    what will be actual issue here?

  • 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