Copied to clipboard

Flag this post as spam?

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


  • John Churchley 272 posts 1258 karma points c-trib
    Jul 25, 2017 @ 07:30
    John Churchley
    0

    Umbraco 7.6 Multi-level Custom Tree

    Hi,

    Any anyone explain or signpost how to create a custom section multi-level tree? CreateTreeNode is set as having children but the following error occurs and the tree query value is missing.

    Thanks

    JC

    Error when opening children on custom tree

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Jul 25, 2017 @ 07:44
    David Brendel
    0

    Hi John,

    can you post how your TreeController looks right now?

    Regards David

  • John Churchley 272 posts 1258 karma points c-trib
    Jul 25, 2017 @ 07:45
    John Churchley
    0
       [PluginController(Constants.PluginName)]
    [Tree(Constants.SectionAlias, "ShowroomsTree", "Showrooms")]
    class ShowroomsTreeController : TreeController
    {
    
        protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
        {
            var menu = new MenuItemCollection();
            menu.DefaultMenuAlias = ActionNew.Instance.Alias;
            menu.Items.Add<ActionNew>("Create");
            return menu;
        }
    
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            TreeNodeCollection menu = new TreeNodeCollection();
    
            //Base Menu
            if (id == "-1")
            {
                Data.Showrooms Showrooms = new Data.Showrooms();
                var showroomsList = Showrooms.GetAll().GroupBy(x => x.Region);
    
                foreach (var key in showroomsList)
                {
                    menu.Add(this.CreateTreeNode(key.Key.Trim().ToString(), id, queryStrings, key.Key.Trim(), "icon-map-location", true, FormDataCollectionExtensions.GetValue<string>(queryStrings, "application") + StringExtensions.EnsureStartsWith(this.TreeAlias, '/') + string.Format("/Edit/{0}", key.Key.Trim().ToString())));
                }
            }
    
    
            //Attempt to Return Children Nodes
            else
            {
                Data.Showrooms Showrooms = new Data.Showrooms();
                var showroomsList = Showrooms.GetAll().Where(x => x.Region == id.Trim());
    
                foreach (var item in showroomsList)
                {
                    menu.Add(CreateTreeNode(item.Id.Trim(), id, queryStrings, item.Name.Trim(), "icon-store", true));
    
                }
            }
    
            return menu;
        }
    
    
    }
    
  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Jul 25, 2017 @ 08:43
    David Brendel
    100

    Hi John,

    not sure if it is the error but maybe try adding the public modifier to your class. Besides that, the only thing I can think of is some mismatch of the alias used for tree alias, tree title or section alias.

    Rest looks ok for me.

    Regards David

  • John Churchley 272 posts 1258 karma points c-trib
    Jul 25, 2017 @ 09:23
    John Churchley
    0

    Eureka, it was the public modifier. Thanks David.

Please Sign in or register to post replies

Write your reply to:

Draft