Copied to clipboard

Flag this post as spam?

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


  • Jeremy 1 post 21 karma points
    Jun 10, 2014 @ 19:57
    Jeremy
    0

    Custom Tree CreateRootNode And Render Methods Umbraco 6.1.4

    Hello, I recently created a new tree called powerpoint which loads all Documents of my custom document type PowerPoint. I can create the tree and it loads just fine under the root node but when I go to expand a powerpoint file and show all of its children (another custom document type) of type slide the tree re-renders all of the powerpoint documents under it and i get none of the slide documents. For some reason, even when the powerpoint is expanded the id passed in it still -1, or the root id, thus creating everything under the root all over again. Here is the code:

    protected override void CreateRootNode(ref XmlTreeNode rootNode)

    {

    rootNode.NodeType = TreeAlias;

    //rootNode.NodeID = "init";

    rootNode.Text = "PowerPoint Files";

    rootNode.Menu = new List<IAction> { ActionRefresh.Instance,CRTumbraco.Actions.ActionCreatePpt.Instance };

    }

    public override void Render(ref XmlTree tree)

    {

    var root = new Node(Convert.ToInt32(this.id));

    foreach (Node umbracoNode in root.ChildrenAsList)

    {

    if (umbracoNode.NodeTypeAlias == "PowerPoint" || umbracoNode.NodeTypeAlias == "slide")

    {

    var node = XmlTreeNode.Create(this);

    node.NodeID = umbracoNode.Id.ToString();

    node.Text = umbracoNode.Name.ToString();

    //pptNode.Action = "javascript:openEditPage("+ presentationNode.Id.ToString() +");";

    node.Action = "javascript:openContent(" + umbracoNode.Id + ");";

    node.Menu = new List<IAction>();

    if (umbracoNode.NodeTypeAlias == "PowerPoint")

    {

    node.NodeType = "PowerPoint";

    node.Icon = "../../../App_Plugins/UmbracoMVCBackofficePages/Icons/pptFileIcon.png";

    }

    else

    {

    node.NodeType = "slide";

    node.Icon = "../../../App_Plugins/UmbracoMVCBackofficePages/Icons/slideIcon.png";

    }

    node.HasChildren = umbracoNode.Children.Count > 0;

    node.Source = node.HasChildren ? GetTreeServiceUrl(node.NodeID) : "";

    OnBeforeNodeRender(ref tree, ref node, EventArgs.Empty);

    if (node != null)

    {

    tree.Add(node);

    }

    }

    }

    }

  • 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