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

[Solved] Panel Bar Binding to SiteMap does not work

1 Answer 100 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Frank Michael
Top achievements
Rank 1
Frank Michael asked on 30 Apr 2010, 04:34 PM
I have this site map:

<?xml version="1.0" encoding="utf-8" ?> 
<siteMap> 
    <siteMapNode title="Home"
        <siteMapNode title="Workstream"
            <siteMapNode controller="Workitem" action="Index" title="Workitems" /> 
            <siteMapNode controller="Sprint" action="Index" title="Sprints" /> 
            <siteMapNode controller="Chart" action="BurndownChicDiagram" title="Burndown Diagram" /> 
        </siteMapNode> 
        <siteMapNode title="Financial"
            <siteMapNode controller="Payment" action="Index" title="Payments" /> 
            <siteMapNode controller="RegularPayment" action="Index" title="Regular Payments" /> 
            <siteMapNode controller="Transaction" action="Index" title="Transactions" /> 
            <siteMapNode controller="Statement"  action="Index" title="Statement" /> 
            <siteMapNode controller="MinMax"  action="Index" title="Minimum Maximum Overview" /> 
            <siteMapNode controller="Chart" action="StatementChicDiagram" title="Statement Diagram" /> 
            <siteMapNode controller="Chart" action="MinMaxChicDiagram" title="Minimum Maximum Diagram" /> 
        </siteMapNode> 
    </siteMapNode> 
</siteMap> 

and this page:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> 
<%@ Import Namespace="Telerik.Web.Mvc" %> 
<%  
 
    if (ViewData["WorkstreamPlatform_WebRole.Menu"] != null) 
    { 
        Html.Telerik().PanelBar() 
            .Name("navigation-product-examples") 
            .HtmlAttributes(new { @class = "demos-navigation" }) 
            .BindTo("WorkstreamPlatform_WebRole.Menu") 
            .HighlightPath(true) 
            .ItemAction(item => 
            { 
                if (!item.Items.Any() && !string.IsNullOrEmpty(Request.QueryString["theme"])) 
                { 
                    item.RouteValues.Add("theme", Request.QueryString["theme"]); 
                } 
 
                if (item.Selected) 
                { 
                    item.HtmlAttributes["class"] = "active-page"; 
                } 
 
                if (item.Parent == null) 
                { 
                    item.SpriteCssClasses = "t" + item.Text; 
                } 
            }) 
            .Render(); 
    } 
     
%> 
 

and this Controller Action:

        [PopulateSiteMap(SiteMapName = "sample", ViewDataKey = "WorkstreamPlatform_WebRole.Menu")] 
        public ActionResult Index() 
        { 
            ViewData["Message"] = "Welcome to ASP.NET MVC!"
 
            if (!SiteMapManager.SiteMaps.ContainsKey("sample")) 
            { 
                SiteMapManager.SiteMaps.Register<XmlSiteMap>("sample", sitmap => sitmap.LoadFrom("~/Web.sitemap")); 
            } 
 
            return View(); 
        } 
 

It is very close to the sample, but does not work. The first level items are shown, but the second level items not.
Previously I had a situation where the first first level item (Workstream) did not expand, but the second (Financial) did expand. But since then I have made some changes, and I do not know the exact condition. So the current symptom is, that the first level items do not expand.
What bothers me as well I do not understand the general flow of the samle code.
In the sample there is an action:
public partial class MenuController : Controller 
    { 
        [PopulateSiteMap(SiteMapName = "sample", ViewDataKey = "sample")] 
        [SourceCodeFile("Sitemap""~/sample.sitemap")] 
        public ActionResult SiteMapBinding() 
        { 
            if (!SiteMapManager.SiteMaps.ContainsKey("sample")) 
            { 
                SiteMapManager.SiteMaps.Register<XmlSiteMap>("sample", sitmap => sitmap.LoadFrom("~/sample.sitemap")); 
            } 
 
            return View(); 
        } 
    } 
It is not in the Home Controller
It is not clear to me when in the general flow this action is called. It seems to me that this is a callback from the client, but I am not sure. With my project, the action is never called. What can I do to understand the general flow? Is there an overview chart for this?
By the way: What does [SourceCodeFile...] mean? What is it for?


1 Answer, 1 is accepted

Sort by
0
Frank Michael
Top achievements
Rank 1
answered on 30 Apr 2010, 05:18 PM
This is the html
<li class="t-item t-state-default"><class="t-link t-header" href="#"><span class="t-sprite tWorkstream"></span>Workstream<span class="t-icon t-arrow-down"></span></a></li><li class="t-item t-state-default"><class="t-link t-header" href="#"><span class="t-sprite tFinancial"></span>Financial<span class="t-icon t-arrow-down"></span></a></li> 

Tags
PanelBar
Asked by
Frank Michael
Top achievements
Rank 1
Answers by
Frank Michael
Top achievements
Rank 1
Share this question
or