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

Determine size of ContextMenu before showing???

3 Answers 322 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 24 Jun 2010, 08:19 PM
I'm trying to manually position my context menu, but need some method of finding it's rendered size prior to it actually being shown.

Is this possible?

I have a handle to the object with:

var contextMenu = $find("<%= RadContextMenu1.ClientID %>");

is there some property or method to get its height/width?



3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 25 Jun 2010, 08:29 AM
Hi Kevin,

I'm afraid that you cannot get the size of the menu before it's shown - its width and height are 0.  You can use OnClientShown event and recalculate its position.

Kind 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
0
Kevin
Top achievements
Rank 1
answered on 25 Jun 2010, 03:52 PM
OK, cool... I can work with that... but how do I get the dimensions of the popup in this OnClientShown method?
0
Yana
Telerik team
answered on 28 Jun 2010, 09:41 AM
Hello Kevin,

You can use the following approach:

<telerik:RadContextMenu ID="RadContextMenu1" runat="server" OnClientShown="clientShown" >       
    <Targets>
        <telerik:ContextMenuDocumentTarget />
    </Targets>
    <Items>
        <telerik:RadMenuItem Text="item 1" />
        <telerik:RadMenuItem Text="item 2" />
        <telerik:RadMenuItem Text="item 3" />
    </Items>
</telerik:RadContextMenu>

and the javascript function:

<script type="text/javascript">
    function clientShown(sender, args) {
        var menuElement = sender.get_childListElement().parentNode;
        var width = menuElement.clientWidth;
        var height = menuElement.clientHeight;        
    }
</script>

All the best,
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
Tags
Menu
Asked by
Kevin
Top achievements
Rank 1
Answers by
Yana
Telerik team
Kevin
Top achievements
Rank 1
Share this question
or