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

Forums / Developing with Sitefinity / Pre-Expanded Two-Level Page Menu

Pre-Expanded Two-Level Page Menu

2 posts, 0 answered
  1. Joe Page
    Joe Page avatar
    4 posts
    Registered:
    18 Aug 2005
    29 Jan 2010
    Link to this post
    We would like to have our left-side navigation display two levels of menus already expanded.
    No mouseover, no ajax, no javascript, ...  just a simple two-level menu, like:

    News
        Headline 1
        Headline 2
        Headline 3
    Research
    Contact Us

    Where News, Research, Contact Us are children pages to the current page, and Headline 1, Headline 2, and Headline 3 are children for the News page.


    I've tried using the Site Menu, Site Panelbar, and Site Treeview navigation items and can't seem to get around all the fancy stuff that they enable.
    It's as if I'm suffering from trying to do something too simple.

    Any help would certainly be appreciated.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    01 Feb 2010
    Link to this post
    Hello Joe Page,

    You can add the code below to OnPreRender event of SitePanelBar control. The code expands all child items of the first RadPanelItem from our current node.

    CmsSiteMapNode item1 = SiteMap.CurrentNode as CmsSiteMapNode;
        if (item1 != null && item1.HasChildNodes)
        {
            // this gets the first node
            SiteMapNodeCollection nodecollection = item1.GetAllNodes();
            foreach (SiteMapNode n in nodecollection)
            {
                 
                if (n != null && n.HasChildNodes)
                {
                    // get the RadPanelItem
                    RadPanelItem panelBarItem = RadPanelbar1.FindItemByText(n.Title);
                    if (panelBarItem != null && panelBarItem.Level == 1)
                    {
                        //if there are childs we expand the RadPanelItem
                        if (panelBarItem.Items.Count > 0)
                        {
                            panelBarItem.Expanded = true;
                        }
                    }
                }
            }
       }

    You can use get_selectedItem(); and RadPanelBar client side API, but you cannot do this  OnClientLoad because the RadPanelBar is still null.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered