Copied to clipboard

Flag this post as spam?

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


  • Rob S 2 posts 72 karma points
    Mar 23, 2020 @ 20:22
    Rob S
    0

    Custom Section MenuItem with Custom Action

    Hi guys,

    I have a custom section in Umbraco 8.5.4. This section utilizes a Nagivation tree which is broken down into a few pieces. Here's a quick example...

    Root

    • Active Events
      • Event 1
      • Event 2
    • Inactive Events
      • Event 3
      • Event 4

    I have an action on each of the individual inactive events called "Activate". The idea is when you click that from the context menu, it will perform some actions (either in C# or via a webapi (in turn performing some C# logic) which will update the event details to "activate it" and then refresh the menu to show that the item has moved out of that node structure into the right place.

    Quick code example:

    protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
        {
            // create a Menu Item Collection to return so people can interact with the nodes in your tree
            var menu = new MenuItemCollection();
    
            if (id == Constants.System.Root.ToInvariantString())
            {
                return menu;
            }
            // add a delete action to each individual item
            //menu.Items.Add<ActionDelete>(Services.TextService, true, opensDialog: true);
    
            menu.Items.Add(new MenuItem("Activate", "Activate"));
            return menu;
        }
    

    My issue is that I can't figure out how to execute an action. I know when I click "Activate" now, it loads up a Activate.html view. In a perfect world, I would either want to show a dialog to confirm activation or just have it activate it (the user could then de-activate it from the Active list if it was an accident).

    Can someone help guide me to some examples or documentation showing how this might be done? I could throw away doing this in the umbraco Tree structure and simply have a table view/admin page, but I'm really trying to make it "feel" as umbraco-ey as possible.

    Thanks in advance!

Please Sign in or register to post replies

Write your reply to:

Draft