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

Forums / Designing with Sitefinity / Submenu Item Auto Height?

Submenu Item Auto Height?

3 posts, 0 answered
  1. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    15 Jul 2010
    Link to this post
    Hi there,

    I have a rad menu on my page. The top level is set to have Flow="vertical" then sub menu items expand horizontally from there. For my First level I have a set height and this is ok as the top level items won't change. However there are a number of submenu items where the menu text could be quite long and needs to wrap. The sub menu items have a max width (185px in my case) and I want the height of each menu item to adjust based on the text. I'm pulling my hair out trying to get this to work. I would think this should be pretty simple edit in the menu css file but I just can't get it.

    As always any help/sample code is greatly appreciated.

    Cheers,
    Phill
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Jul 2010
    Link to this post
    Hi Phill Hodgkinson,

    You could dynamically change the with of the RadMenuItem inside Page_Load of your control which contains RadMenu RadControl.

      protected void Page_Load(object sender, EventArgs e)
      {
          RadMenu1.DataBind();
          foreach (RadMenuItem item in RadMenu1.GetAllItems())
          {
              if (item.Text.Length <= 5)
              {
                  item.Width = Unit.Pixel(30);
              }
              if (item.Text.Length < 10 && item.Text.Length > 5)
              {
                  item.Width = Unit.Pixel(40);
              }
          }
    }



    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    16 Jul 2010
    Link to this post
    Hi Ivan,

    Thanks for your reply, unfortunately this is the exact opposite of what I want to do. I need the width to stay the same (there's a background color/design so it would look strange if one sub menu item was 30px wide and then the item right next to it suddenly stuck out 10px more.

    Is there really no way to have radmenu rmGroups have flexibility in their height? Since I'm using it in sitefinity where users can create menu labels of any length it seems like this would be a very common requirement as I never know what length they're going to enter. I know technically it can be doing using an unordered list and css, it's just that I can't figure out what it is in the base style sheet that is preventing it, yet if I remove the base style sheet the menu falls apart visually.

    Any other ideas?

    Thanks again!
    Phill
Register for webinar
3 posts, 0 answered