Possible to add .Content with sitemap?

2 posts, 1 answers
  1. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 18 Dec 2012 Link to this post

    Hello,

    I have a menu that I would like to use content in such as the "Stores" menu option in the example found here.  Basically I want to add HTML markup to a parent menu item.  Is this possible?

    Thank you,
    David A.
  2. Answer
    Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 19 Dec 2012 Link to this post

    Hello David,

    The work-around which you can use is to use the overload which accepts sitemapitem action. There you can set the text to be the actual content and you can set the encoded option to false.
    e.g.


    @(Html.Kendo().Menu()
          .Name("Menu")
          .BindTo("sample", (item, node) =>
          {
              item.Encoded = false ;
              item.Text = node.Attributes["foo"] == null ? "<h1>test</h1>" : "<h1>" + node.Attributes["foo"].ToString() + "</h1>";
          })
     
    )

    In the snippet above foo is an attribute in the sitemap xml.

    i.e.

    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap>
      <siteMapNode title="Home" controller="Home" action="Overview">
        <siteMapNode title="Grid">
          <siteMapNode controller="grid" foo="bar baz" action="index" title="First Look (Razor)" area="razor"/>
          <siteMapNode controller="grid" action="index" title="First Look (ASPX)" area="aspx"/>

    I hope this helps.

    All the best,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top