Menu width width scrolling feature

2 posts, 1 answers
  1. pirobox
    pirobox avatar
    16 posts
    Member since:
    Nov 2009

    Posted 31 Aug 2010 Link to this post

    Hi,
    I've the following problem I can't solve alone (I'm using 2010Q2).
    I've a menu with EnableRootItemScroll="true", that is, I'd like to have the menu on only one line and if there is not enough space I'd like to see the scrolling arrows.
    Everything was working perfectly until I started to work client side with item texts and visibility.
    I explain: in the menu I've a button that must work as a warning label, that is, if something is wrong I change client side its text (and image) to show a warning message to the user.
    The problem is that when I do so the menu starts to be shown on multiple line.
    I've debugged a bit the JS and I've found out that you calculate the width of all the root items when the page is rendered and assign the total to the <UL> container. Changing the text, the width should change.

    I've already tried this:
    function recalculateWidth()
    {
    var menu1 = $find("<%= Menu1.ClientID %>");
    var menuItems = menu1.get_items();
    var newWidth = 0;
    for (var i = 0; i < menuItems.get_count(); i++)
    newWidth += menuItems.getItem(i).get_element().offsetWidth;
    menu1.get_childListElement().style.width = newWidth;
    }
    and apparently it works, that is, the menu no longer is displayed on more than one line, but the scrolling arrows behave weirdly: the rightmost buttons are being cut off. It is like you are setting the width also into the scrolling arrows mechanism, but I can't find it.
    May you help me with this?

    Best regards, Andrea Pirola
  2. Answer
    Yana
    Admin
    Yana avatar
    5043 posts

    Posted 31 Aug 2010 Link to this post

    Hello Andrea,

    Could you please try to call repaint() method of the client-side object of the menu after these changes?  It should recalculate the width, so you don't need to do it manually.

    Regards,
    Yana
    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
Back to Top