This is a migrated thread and some comments may be shown as answers.

Getting and setting width client side

1 Answer 136 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
John asked on 19 Nov 2012, 05:31 PM

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?



1 Answer, 1 is accepted

Sort by
Telerik team
answered on 22 Nov 2012, 01:50 PM
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.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question