Copied to clipboard

Flag this post as spam?

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


  • Arnold Visser 418 posts 778 karma points hq c-trib
    Sep 07, 2010 @ 10:58
    Arnold Visser
    0

    Custom Tree Context Menu based on document type

    After trying for some time now, I just have to ask here...

    I would like to define the "CreateAllowedActions" for a custom tree based on their doctype.

    Things like:

     

     

    if (Node.GetCurrent().NodeTypeAlias("XXXXX");
    {
      actions.Add(ActionPublish.Instance);
    }

    or

     

                if (!string.IsNullOrEmpty(this.NodeKey))
                {
                    var node = new Node(int.Parse(this.NodeKey));
                    if (node.Parent != null)
                    {
                        switch (node.NodeTypeAlias)
                       {
                            case "XXXXX":
                                actions.Clear();                             actions.Add(ActionNew.Instance);                             actions.Add(ContextMenuSeperator.Instance);                             actions.Add(ActionPublish.Instance);                             actions.Add(ContextMenuSeperator.Instance);                             actions.Add(ActionRefresh.Instance);                             break;                     }                 }             }

     

    Don't work...

    Anyone can point me in the right direction?

     

     

  • Shannon Deminick 1526 posts 5272 karma points MVP 3x
    Sep 07, 2010 @ 11:03
    Shannon Deminick
    0

    What tree are you overriding?

    What method(s) are you overriding?

    can you post the whole method?

  • Arnold Visser 418 posts 778 karma points hq c-trib
    Sep 07, 2010 @ 11:06
    Arnold Visser
    0

    What I do is just get a specified NodeID from the content tree and split that to a custom tree:

        public class LoadCustomTree : BaseContentTree
       {
            public override int StartNodeID
            {
                get
                {
                    var nodeId = DomainHelper.GetNodeIdForDocument("XXXXX", "XXXXX");
    
                   return nodeId;
                }
            }
    
            public LoadCustomTree(string application)
                : base(application)
            {
                this.DialogMode = TreeDialogModes.id;
                this.IsDialog = false;
            }
    
            protected override void CreateRootNode(ref XmlTreeNode rootNode)        
        {
                rootNode.Icon = "XXXXX.png";
                rootNode.OpenIcon = "XXXXX.png";
                rootNode.NodeType = "init" + TreeAlias;
                rootNode.NodeID = "init";
            }
    
            protected override void CreateRootNodeActions(ref List<IAction> actions)
            {
                actions.Clear();
                actions.Add(ActionRefresh.Instance);
            }
        
       protected override void CreateAllowedActions(ref List<IAction> actions)
            {
        }
    
           public override void Render(ref XmlTree tree)
            {
                base.Render(ref tree);
            }
    
            public override void RenderJS(ref StringBuilder Javascript)
            {
                Javascript.Append(
                   @"
                        function openCustom(id) {
                         parent.right.document.location.href = 'editContent.aspx?id=' + id;
                        }
                    ");
            }
        }

     

     

  • Shannon Deminick 1526 posts 5272 karma points MVP 3x
    Sep 07, 2010 @ 11:37
    Shannon Deminick
    1

    well, you will have to assign custom actions to the XmlTreeNodes that are created from the Render method.

    The CreateAllowedActions method is only useful for creating a Global set of actions for all of your nodes. If you want to customize the actions for specific nodes, you will need to change them in render.

    So after you call base.Render(ref tree);

    you will be able to iterate through the nodes of the tree and change the nodes allowed actions based on your criteria.

     

    FYI: You don't have to create your own tree to do this anymore in v4.5, there are events that you can bind to in order to change the node before it is rendered.

    see the AfterNodeRender event of the loadContent tree (that is if you want to modify the normal content tree actions)

  • Arnold Visser 418 posts 778 karma points hq c-trib
    Sep 07, 2010 @ 11:39
    Arnold Visser
    0

    Ah that brightens my thoughts!

    Let me see how far your info will bring me.

    Thank you very much! 

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Sep 07, 2010 @ 12:08
    Richard Soeteman
    0

    Hi Arnold,

    For an example how to manipulate actions check out this WIKI

    Cheers,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft