This is a migrated thread and some comments may be shown as answers.

[Solved] Changes to MVC Menu in Q2 Release

1 Answer 41 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jamie
Top achievements
Rank 1
Jamie asked on 16 Aug 2011, 07:59 PM
Something broke when I upgraded form the Q1 release to the Q2 release of the MVC Menu.

Under the hood, I have the following object representing my menu:

    [Serializable()]
    public class Menu : List<MenuItem>
    {
    }
 
    [Serializable()]
    public class MenuItem
    {
        public long ItemId { getset; }
        public string Text { getset; }
        public string Type { getset; }
        public string Url { getset; }
        public long ObjectId { getset; }
        public Menu Children { getset; }
        public bool Selected { getset; }
        public MenuItem()
        {
            Selected = false;
        }
    }

I have the following code that worked prior to upgrading:

@{
    MySite.Menu menu = ViewBag.Menu;
}
@if (menu != null)
{
    Html.Telerik().Menu().Name("SiteMenu").BindTo(menu, mappings =>
    {
        mappings.For<MySite.MenuItem>(binding => binding
          .ItemDataBound((item, menuItem) =>
          {
              item.Text = menuItem.Text;
              if (menuItem.Url != null) item.Url = menuItem.Url;
              item.Selected = menuItem.Selected;
          })
          .Children(menuItem => menuItem.Children)
        );
    });
}

I use the Telerik CDN, so my stylesheets and javascript are correct for the version:

<script type="text/javascript" src="http://aspnet-scripts.telerikstatic.com/mvcz/2011.2.712/telerik.common.min.js"></script>
<script type="text/javascript" src="http://aspnet-scripts.telerikstatic.com/mvcz/2011.2.712/telerik.menu.min.js"></script>

It appears that the problem is that the actual HTML markup is not being output in the page. Not even the SiteMenu div.

I tried looking through the release notes, but I didn't see anything that should have changed.

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 17 Aug 2011, 08:27 AM
Hello Dave,

 
After quick review of the code snippet I noticed that you are using Menu UI component in a code block without calling the Render() method. Thus the component will not be rendered. Check the attached test project. I have test the provided code snippet with Q1 version and the menu does not render if there is no Render() method.

Best regards,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Tags
Menu
Asked by
Jamie
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or