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

Forums / Designing with Sitefinity / Highlight the rootGroup in a menu if child item is selected

Highlight the rootGroup in a menu if child item is selected

5 posts, 0 answered
  1. chris_cf
    chris_cf avatar
    32 posts
    Registered:
    04 Jul 2007
    30 Oct 2008
    Link to this post
    Is there a way to highlight the rootGroup item if one of its child items are selected? I know this functionality exists in DNN with rootGroup_Selected as the class or something.
  2. chris_cf
    chris_cf avatar
    32 posts
    Registered:
    04 Jul 2007
    31 Oct 2008
    Link to this post
    Anyone? Any clues?
  3. chris_cf
    chris_cf avatar
    32 posts
    Registered:
    04 Jul 2007
    01 Nov 2008
    Link to this post
    I dug deeper into this and found out that when you use the following code to only display root level items in the panelbar, it removed the rpExpanded CSS Class from the root menu item whose child item is currently selected:

    if (e.Item.Level > 0)
    {
    e.Item.Visible = false;
    e.Item.Owner.Items.Clear();
    }

    I had to add this within the if statement to make it work:

    if (e.Item.Selected)
    {
    ((RadPanelItem)e.Item.Owner).CssClass = "rpExpanded";
    }

    This is undesirable as I have to specify the class name in code.

    Is there another way of handling this?
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    08 Dec 2016
    04 Nov 2008
    Link to this post
    Hello Chris,

    You could implement a property that gets/sets the name of the CSS class that should be applied. For example:

    public void RadPanelbar1_ItemDataBound(object sender, RadPanelBarEventArgs e) 
        { 
            ... 
     
            if ((e.Item.Selected) && (e.Item.Owner is RadPanelItem)) 
            { 
                ((RadPanelItem)e.Item.Owner).CssClass = this.OwnerCssClass; 
            } 
        } 
     
        [Category("Appearance")] 
        public string OwnerCssClass 
        { 
            get { return this.ownerCssClass; } 
            set { this.ownerCssClass = value; } 
        } 
     
        private string ownerCssClass; 

    Then, you could set the CSS class name through Sitefinity interface and not through the code.

    Hope this helps.

    Sincerely yours,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. chris_cf
    chris_cf avatar
    32 posts
    Registered:
    04 Jul 2007
    04 Nov 2008
    Link to this post
    Thanks Pepi, this works wonderfully.
Register for webinar
5 posts, 0 answered