SitefinitySiteMap and RadPanelbar issue with empty nodes

Posted by Community Admin on 04-Aug-2018 13:58

SitefinitySiteMap and RadPanelbar issue with empty nodes

All Replies

Posted by Community Admin on 14-Oct-2011 00:00

Hi all,

I've created a custom usercontrol for displaying a sidemenu.
I've used a SiteMapDataSource (based on the SitefinitySiteMap) and a default RadPanelbar.

When I don't have any subpages, it still renders 3 empty <li> tags. What are those things and how to get rid of them?

This is my code:

Subnavigation.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Subnavigation.ascx.cs"
    Inherits="SitefinityWebApp.Custom.General.Subnavigation" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI"
    TagPrefix="sf" %>
<telerik:RadPanelBar ID="sideNavigation" runat="server" EnableEmbeddedBaseStylesheet="false"
    EnableEmbeddedSkins="false" DataSourceID="sfDatasource" Skin="EexSidebar">
</telerik:RadPanelBar>
<asp:SiteMapDataSource ID="sfDatasource" runat="server" SiteMapProvider="SitefinitySiteMap"
    ShowStartingNode="false" StartFromCurrentNode="false" StartingNodeOffset="1" />

Subnavigation.ascx.cs
public partial class Subnavigation : System.Web.UI.UserControl
 
        protected void Page_Load(object sender, EventArgs e)
 
            this.sideNavigation.ItemDataBound += new RadPanelBarEventHandler(sideNavigation_ItemDataBound);
        
 
        void sideNavigation_ItemDataBound(object sender, RadPanelBarEventArgs e)
 
            var item = e.Item.DataItem as PageSiteNode;
            if (!item.ShowInNavigation)
                e.Item.Visible = false;
        
    

It renders the following output:
<div id="ctl00_ContentSidebar_T4181E1D7007_sideNavigation" class="RadPanelBar RadPanelBar_EexSidebar">
<ul class="rpRootGroup">
<li class="rpItem rpFirst"></li>
<li class="rpItem"></li>
<li class="rpItem rpLast"></li>
</ul>
</div>

But... there are no childnodes for the current page.

What is the problem here?

Regards,
Daniel

Posted by Community Admin on 14-Oct-2011 00:00

Try this instead

<sitefinity:SitefinitySiteMapDataSource ID="sfDatasource" runat="server" ShowStartingNode="false" />

And comment out all your code-behind databound code

It should have better performance and handle the Show In Navigation by itself.

Posted by Community Admin on 14-Oct-2011 00:00

Thanks, give it a try. -Daniel-

This thread is closed