Sitefinity: Keeping RadPanelBar Expanded

By in
No comments

If you need to ensure that the RadPanelBar control (which I use for sidebar navigation) remains expanded, check out the RadPanelbar1_ItemDataBound method in the control located at /Sitefinity/UserControls/Navigation35/SitePanelBar.ascx.

This control checks the hideUrlForGroupPages, removing the link if set to true on your control. However, this doesn’t prevent the link from being active, collapsing the nodes when clicked. I need my menu to be fully expanded, so I modified the code using some newly discovered properties in the e (RadPanelEventArgs) parameter:

public void RadPanelbar1_ItemDataBound(object sender, RadPanelBarEventArgs e)
{
    if (!hideUrlForGroupPages) return;

    var node = e.Item.DataItem as CmsSiteMapNode;
    if (node == null || node.PageType != CmsPageType.Group) return;

    e.Item.NavigateUrl = "";
    e.Item.PreventCollapse = true;
    e.Item.Enabled = false;
}

Since the item is always rendered as a link, it’s important to disable it as well so that it doesn’t do anything when clicked. Additionally, since it still renders as a link, the pointer still turns into a cursor, and when you click the heading, that annoying dotted border still activates as if it’s a regular link. We can fix this with css:


.rpRootGroup .rpSlide a

{
    outline: none;
    cursor: default
}

Additionally, you might need to undo this change in lower levels of the css, but that depends on your application.

I don’t have an example (yet) as we haven’t published our site (yet), but hope to update this with a link soon. Hope this was helpful! As always, comments are welcome.

The following two tabs change content below.

selaromdotnet

Senior Developer at iD Tech
Josh loves all things Microsoft and Windows, and develops solutions for Web, Desktop and Mobile using the .NET Framework, Azure, UWP and everything else in the Microsoft Stack. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom. His other passion is music, and in his spare time Josh spins and produces electronic music under the name DJ SelArom.