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
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.
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.
Child nodes in custom Section
{
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?
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
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
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.
You can find more info and some examples at the following topic:
http://our.umbraco.org/forum/developers/extending-umbraco/3080-Add-child-nodes-to-custom-Umbraco-section
thanks., in that i referred dictionaryItems..
How did you implemented it
hello.,
where to i have to pass this method?
RenderSubtree(tree,"treealias", "somenodetype", "Text");
Did you already looked at the following wiki? http://our.umbraco.org/wiki/reference/backoffice-apis/tree-api---to-create-custom-treesapplications
put this after tree.treeCollection.Add( node);
Also make sure you've configured the tree in the database
Folks.,
i have tried.. it is not working for me..
this is the example code
{
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 );
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?
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):
The child node loads by using:
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.
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
I couldn't completely understand your last message but did you solve your problem? If so you should mark a reply as the solution.
still i am getting repeated nodes
hello.,
i am getting infinite repeated nodes..
what will be actual issue here?
is working on a reply...
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.