Clicking on Section Icon Changes Name of Tree Nodes
I'm creating a new section and I'm currently working on implementing the Tree for this section. On page load, everything looks fine but if I navigate to another section and then come back to this new section, every node of the tree in this section now has a name combining all five nodes' names into one name. If I navigate to another section again it appends all five names again and again to the point that I might have a string consisting of all five node names repeated five or six times. My trees.cs code is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using umbraco.businesslogic;
using umbraco.cms.presentation.Trees;
[Tree("howard", "howardTree", "Howard")]
public class HowardTree : BaseTree
{
public HowardTree(string application) : base(application)
I remember I had a similar issue once .. and from what I can see on my previously code examples you need to add a unique NodeID ... also you might add .Menu.Clear(); which I think was not to get the full context menu, but I am not sure..
and this for each tree node ... notice the second line with NodeID :
var contacts = XmlTreeNode.Create(this);
contacts.NodeID = "uniqueContacts";
contacts.Text = "Contacts";
contacts.Icon = "docPic.gif";
contacts.Action = "javascript:openContacts()";
contacts.Menu.Clear();
// Add the node to the tree
tree.Add(contacts);
and the same for gifts, sales, campaigns and report nodes..
Clicking on Section Icon Changes Name of Tree Nodes
I'm creating a new section and I'm currently working on implementing the Tree for this section. On page load, everything looks fine but if I navigate to another section and then come back to this new section, every node of the tree in this section now has a name combining all five nodes' names into one name. If I navigate to another section again it appends all five names again and again to the point that I might have a string consisting of all five node names repeated five or six times. My trees.cs code is:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using umbraco.businesslogic;
using umbraco.cms.presentation.Trees;
[Tree("howard", "howardTree", "Howard")]
public class HowardTree : BaseTree
{
public HowardTree(string application) : base(application)
{ }
protected override void CreateRootNode(ref XmlTreeNode rootNode)
{
rootNode.Icon = FolderIcon;
rootNode.OpenIcon = FolderIconOpen;
rootNode.NodeType = "init" + TreeAlias;
rootNode.NodeID = "init";
}
public override void Render(ref XmlTree tree)
{
var contacts = XmlTreeNode.Create(this);
contacts.Text = "Contacts";
contacts.Icon = "docPic.gif";
contacts.Action = "javascript:openContacts()";
// Add the node to the tree
tree.Add(contacts);
var gifts = XmlTreeNode.Create(this);
gifts.Text = "Gifts";
gifts.Icon = "docPic.gif";
gifts.Action = "javascript:openGifts()";
// Add the node to the tree
tree.Add(gifts);
var sales = XmlTreeNode.Create(this);
sales.Text = "Sales";
sales.Icon = "docPic.gif";
sales.Action = "javascript:openSales()";
// Add the node to the tree
tree.Add(sales);
var campaigns = XmlTreeNode.Create(this);
campaigns.Text = "Campaigns";
campaigns.Icon = "docPic.gif";
campaigns.Action = "javascript:openCampaigns()";
// Add the node to the tree
tree.Add(campaigns);
var reports = XmlTreeNode.Create(this);
reports.Text = "Reports";
reports.Icon = "docPic.gif";
reports.Action = "javascript:openReports()";
// Add the node to the tree
tree.Add(reports);
}
public override void RenderJS(ref StringBuilder Javascript)
{
Javascript.Append(@"
function openContacts() {
parent.right.document.location.href = 'howard/contacts.aspx';
}
");
Javascript.Append(@"
function openGifts() {
parent.right.document.location.href = 'howard/gifts.aspx';
}
");
Javascript.Append(@"
function openSales() {
parent.right.document.location.href = 'howard/sales.aspx';
}
");
Javascript.Append(@"
function openCampaigns() {
parent.right.document.location.href = 'howard/campaigns.aspx';
}
");
Javascript.Append(@"
function openReports() {
parent.right.document.location.href = 'howard/reports.aspx';
}
");
}
}
Hi Anthony
I remember I had a similar issue once .. and from what I can see on my previously code examples you need to add a unique NodeID ... also you might add .Menu.Clear(); which I think was not to get the full context menu, but I am not sure..
So try change you code to this:
and this for each tree node ... notice the second line with NodeID :
and the same for gifts, sales, campaigns and report nodes..
/Bjarne
This fixed it thanks so much this was driving me nuts.
I'm glad I could help :)
/Bjarne
is working on a reply...