CodeGarden 10: The sixth annual Umbraco Developer Conference
June 23-25th 2010 - free ASP.NET MVC pre-conference. Register today!

how to properly change the name of a tree node in a custom tree

6/23/2009 10:00:53 AMAvatarNikola PetkovicLocation: Serbiaposts: 52Karma: 51

Hi all,

I made my custom tree and it works perfectly. I'll explain the only issue I'm hitting:

My custom tree is just a subtree of umbraco Content tree. I wanted to display different name for some node than the original one, so I just changed the text property of a node (xNode.Text = "Custom_Name") and it displays fine.
The problem is that after selecting (clicking) that particular node, it's name changes back to the original one as it is in Content tree.

Any idea how to change the name so it doesnt get back...?

Cheers!

Nikola

6/29/2009 11:13:43 PMAvatarShannon DeminickLocation: Sydney, AustraliaCore.posts: 113Karma: 230
Comment with ID: 8211

You mean you want to rename the root node, normally called 'content' to 'Custom_name'...?

The root node name for all trees is taken from the database umbracoAppTree alias depending on how many trees are being loaded in to the app.

6/30/2009 3:04:29 PMAvatarNikola PetkovicLocation: Serbiaposts: 52Karma: 51
Comment with ID: 8282

Hi Shannon,

Actually I want to be able to display different name for any other node in the tree (root node is fine).
As I said above, I succeeded to to rename them, but after I select a node in the tree, the name gets back to original node name (as it is in Content tree).

Regards,
Nikola

7/2/2009 1:51:01 AMAvatarShannon DeminickLocation: Sydney, AustraliaCore.posts: 113Karma: 230
Comment with ID: 8385

So to get this straight, you've inherited from the loadContent tree and swapped out the loadContent tree for your new custom tree class in the umbracoAppTree table... It renders the nodes out correctly, but when you click on a node, the node text changes to what would have been originally rendered in the loadContent tree?

...  Not sure if i fully understand. Is the above statement correct?

7/2/2009 2:03:58 PMAvatarNikola PetkovicLocation: Serbiaposts: 52Karma: 51
Comment with ID: 8437

You got it right.

Except, I inherited from BaseTree instead from loadContent tree, so I get content nodes by

Document[] nodes = Document.GetChildrenForTree(root_id);

and then set their names manually.

7/4/2009 4:50:36 AMAvatarShannon DeminickLocation: Sydney, AustraliaCore.posts: 113Karma: 230
Comment with ID: 8550

Ahh, ok. How are you setting the node's source property? Perhaps, the ajax request for the child nodes once your initial tree is loaded is querying for nodes from loadContent tree instead of your tree....

When you say you click on the node and the name changes, is that because when you click on the node the current tree branch refreshes?

7/7/2009 12:06:23 PMAvatarNikola PetkovicLocation: Serbiaposts: 52Karma: 51
Comment with ID: 8783

Actually I am not sure if the whole tree branch "refreshes", but it certainly does not behave as when its reloaded by clicking "Reload nodes" action (so you a dial clock is displayed)

I think that its just the tree node that is somehow being "refreshed" so its name changes.

Please login or Sign up To post replies