This was something i was looking for for a while- turns out it is buried deep in their forums;
As shown in their own example (I’ve reblogged here incase the page ever moves or dissapears!!)
Turns out it’s just a case of setting the “source” property of the XmlTreeNode.
public override void Render(ref XmlTree tree)
{
Dictionary.DictionaryItem[] tmp;
//this.id is set when the tree.aspx creates this object.
//It is the nodeID that is passed in via the tree service parameters (i.e. the query string)
//this checks if the id is the StartNodeID (root node), if it’s not then this will
//look up the child nodes for the current dictionary item.
if (this.id == this.StartNodeID)
tmp = Dictionary.getTopMostItems;
else
tmp = new Dictionary.DictionaryItem(this.id).Children;
foreach (Dictionary.DictionaryItem di in tmp)
{
XmlTreeNode xNode = XmlTreeNode.Create(this);
xNode.NodeID = di.id.ToString();
xNode.Text = di.key;
xNode.Action = string.Format("javascript:openDictionaryItem({0});", di.id);
xNode.Icon = "settingDataType.gif";
xNode.OpenIcon = "settingDataType.gif";
//if there is no children, then set the source to an empty string
//this will ensure that there is no expand button for this node when it is
//rendered. Otherwise, set the source to the tree service url by using
//the BaseTree’s GetTreeServiceUrl method
xNode.Source = di.hasChildren ? this.GetTreeServiceUrl(di.id) : "";
tree.Add(xNode);
}
}
Related posts:











#1 by Jason at January 25th, 2010
Hey, when I implemented this there was a logic error on the xNode.Source setting.
The child node needs to have its parent id set as the source.
Unless I’m reading it wrong (I’m not using dictionaries) I think this line may be wrong:
xNode.Source = di.hasChildren ? this.GetTreeServiceUrl(di.id) : “”;
It loos like its setting its parent to itself. However, I don’t have a way to test this specific case.
#2 by Jason at January 25th, 2010
Nonetheless, thanks for the code and the blog. It got me going fast on this problem!
#3 by shawson at January 27th, 2010
Hey Jason,
Thanks for posting, Glad it helped! To be honest, I’m not sure- I got lucky finding that amongst the masses of disorganised forum posts and I pasted it straight in and it just worked.
I can’t say for sure if your interpretation of the code is right without knowing what the GetTreeServiceUrl method does; that might all I can say is that I have that same code snippet up and powering a custom “job application” section on the backend of bookpoint.co.uk and all is live and working as expected.
Its a shame really- as much as I like what the Umbraco guys have done, I found the documentation to he a massive let down to the project.