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

Forums / Designing with Sitefinity / Question About SiteMenu Control

Question About SiteMenu Control

2 posts, 0 answered
  1. Brian
    Brian avatar
    31 posts
    Registered:
    25 Jun 2009
    13 Nov 2009
    Link to this post
    I been working on this for a little while now & just can't figure out how to make the SiteMenu control work the way I need it to.  Basically I have some root level pages & some of those root level pages have child pages.  I would only like the parent page group to expand if the user is in one of the child pages of that parent.  Otherwise I would like the parent to remain collapsed.

    Can anyone give me some guidance as to what settings I need to have set on the SiteMenu control & the javascript (if any) that I need to add.  I was thinking I would need an onload event but I'm just not sure who to write that event.

    Thanks,

    Brian
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Nov 2009
    Link to this post
    Hello Brian,

    You need to use js and RadMenu client side API to achieve desired functionality. Below is a sample code that illustrates similar behavior.

    <script type="text/javascript">
        function OnClientLoad() {
            var menu = $find("<%= RadMenu1.ClientID %>");
            var selectedItem = menu.findItemByText("www");
            if (selectedItem != null) {
                var parent = selectedItem.get_parent();
                if (parent != null) {
                    parent.open();
                }
                else {
                  // do something else here
                }
            }
        }
    </script>

    You can use get_selectedItem method to get an item. Helpful links

    Client-Side Basics
    RadMenuItemCollection object
    RadMenuItem object

    All the best,
    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