Binding to an MVC Sitemap

8 posts, 1 answers
  1. DominionZA
    DominionZA avatar
    49 posts
    Member since:
    Jul 2007

    Posted 17 Oct 2013 Link to this post

    Hi am trying to bind my sitemap to the KendoUI Tabstrip. I am having no joy with the MVC Sitemap though.

    If I rename the nodes in my .sitemap from mvcSiteMapNode to siteMapNode then all works. When I change it back to mvcSiteMapNode it won't work. Nothing renders on the page.

    What is the correct way to do this?
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 21 Oct 2013 Link to this post

    Hello,

    The nodes should be named "siteMapNode" and using a different name is not support. The only option to change the name and use the built-in sitemap binding is to modify the source code(XmlSiteMap class, SiteMapNodeName property).

    Regards,
    Daniel
    Telerik
    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
  4. DominionZA
    DominionZA avatar
    49 posts
    Member since:
    Jul 2007

    Posted 21 Oct 2013 Link to this post

    This does not work for me. I am using MVCSiteMapProvider so I have nice tight integration between my SiteMap and MVC framework.
    So you saying I can't use it because Kendo won't integrate too?

    How then can I manually construct my menu based on the sitemap file and mvcSiteMap nodes? I don't mind if I have to do this. I just don't want to have to give up using MVCSiteMapProvider because your menu's and tabs don't support it.
  5. Answer
    Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 23 Oct 2013 Link to this post

    Hello again,

    In that case, you will need to create a collection of objects from the sitemap file and bind them to the menu as described in this documentation topic. I attached a sample project that demonstrates this scenario.

    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. DominionZA
    DominionZA avatar
    49 posts
    Member since:
    Jul 2007

    Posted 23 Oct 2013 Link to this post

    Thanks Daniel. Will try your suggestion out and see how it goes.
  7. DominionZA
    DominionZA avatar
    49 posts
    Member since:
    Jul 2007

    Posted 23 Oct 2013 Link to this post

    Thank-you Daniel. I am up and running with your suggestion.
  8. DominionZA
    DominionZA avatar
    49 posts
    Member since:
    Jul 2007

    Posted 23 Oct 2013 Link to this post

    While on this topic Daniel, please help me to bind the same model from above to your TabStrip.
    We will only ever go one level deep, so a TabStrip may look nicer for this.

    I can get the tabs to bind and show text etc.. but cannot get the content for each tab based on the sitemap children.
  9. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 25 Oct 2013 Link to this post

    Hello,

    You can set the content of the node to the TabStripItem Html property:

    Html.Kendo().TabStrip()
        .Name("tabstrip")
        .BindTo(Model, (item, node) =>
        {
            item.Text = node.Title;
            if (!string.IsNullOrEmpty(node.Html))
            {
                item.Html = node.Html;
            }
            else
            {
                item.ActionName = node.Action;
                item.ControllerName = node.Controller;  
            }
        })
    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready