Getting and setting width client side

2 posts, 0 answers
  1. John
    John avatar
    25 posts
    Member since:
    Mar 2007

    Posted 19 Nov 2012 Link to this post


    I have a RadMenu context menu on my page. Items are added to it and removed from it client side. The problem is the items are not the same width. Some items can be very long in which case they extend past the right boundary of the context menu. Shorter items don't extend to the width of the context menu.

    I thought I could use the ClientShowing method to loop through the items currently in the menu, determine the width of the longest one, then set the width of all the other items to this value. However I can't get the width of any of the items in the menu. The width and offsetwidth properties of each item (and it's linkelement, text element etc) are always 0.

    How do I get the actual value of these?


  2. Kate
    Kate avatar
    1898 posts

    Posted 22 Nov 2012 Link to this post

    Hi Matt,

    Using the code below you can easily set height and width to the RadContextMenu:
    <telerik:RadContextMenu ID="RadContextMenu1" EnableRootItemScroll="true" EnableScreenBoundaryDetection="true"
                    OnClientShown="OnClientItemOpening" EnableAutoScroll="true" runat="server">
                    <DefaultGroupSettings Height="200px" />
                        <telerik:RadMenuItem Text="Item1"></telerik:RadMenuItem>

    function OnClientItemOpening(sender, args) {
                       var scrollWrapElement = sender._getScrollWrapElement();
              = "100px";
              = "500px";

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top