1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / SitePanelbar not expanding/selecting parent items of non-navigable child pages or deeper level pages

SitePanelbar not expanding/selecting parent items of non-navigable child pages or deeper level pages

2 posts, 0 answered
  1. Diana
    Diana avatar
    16 posts
    Registered:
    26 Nov 2008
    13 Feb 2009
    Link to this post

    Hi
    I'm not sure if this is a bug in the SitePanelBar control, or if it is the way it is intended to work, but I just wanted to share my problem and solution. 

    Situation:
    For usability reasons, we are using SitePanelbar on our pages showing a maximum of two levels (set RadPanelbar to have MaxDataBindDepth=2), even though we have more levels in the site map.  We also have some pages (such as a custom details page for a news item) which we'd like to be non-navigable.

    Problem:
    When we have the SitePanelbar included on deeper level or non-navigable pages, we want the parent panelbar items to be selected and expanded.  But since the pages themselves are not included in the Panelbar items, their parents are not selected or expanded.

    Solution:
    Copy or change the SitePanelBar.ascx.cs and do the following in the Page_Load:

        protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!Page.IsPostBack)  
            {  
                ICmsUrlContext urlContext = CmsUrlContext.Current;  
                if (urlContext != null)  
                {  
                    RadPanelbar1.DataBind();  
                    string currentUrl = UrlHelper.ResolveUrl(urlContext.Path);  
                    RadPanelItem item = this.RadPanelbar1.FindItemByUrl(currentUrl);  
                    if (item != null)  
                    {  
                        item.Selected = true;  
                        item.Expanded = true;  
                        item.ExpandParentItems();  
                    }  
     
                    //current page could be a decendant of one of the radpanelitems,   
                    //so we need to check if the parent(s) are in the panelbar in  
                    //order to select/expand them  
                    else 
                    {  
                        //search ancestors of the current node  
                        CmsSiteMapNode node2 = SiteMap.CurrentNode as CmsSiteMapNode;  
     
                        if (node2 != null && node2.ParentNode != null)  
                        {  
                            while (node2.ParentNode != SiteMap.RootNode)  
                            {  
                                node2 = node2.ParentNode as CmsSiteMapNode;  
                                RadPanelItem parentItem =  this.RadPanelbar1.FindItemByUrl(this.ResolveUrl(node2.Url));  
                                if (parentItem != null)  
                                {  
                                    parentItem.Selected = true;  
                                    parentItem.Expanded = true;  
                                    parentItem.ExpandParentItems();  
                                    break;  
                                }  
                            }  
                        }  
                    }  
     
                }  
            }  
     
        } 

     

  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    16 Feb 2009
    Link to this post
    Hi Diana,

    Thanks a lot for sharing your experience with us. As a note of gratitude your Telerik account has been updated.

    Sincerely yours,
    Pepi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered