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

How to with RadMenu And Javascipt

4 Answers 200 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Patrick Williams
Top achievements
Rank 1
Patrick Williams asked on 22 May 2010, 12:42 AM
Hi All,

How do i get the selected value of a RadMenu using javascript. Also could someone give me a list of few or all the javascript functions that are associated with rad controls. 

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 May 2010, 07:25 AM
Hello Patrick,

Use the 'get_selectedItem()'  method to get reference to the selected menu item. And use the get_value() method of menuitem client object to retrieve the value from client side.

aspx:
 
 
<telerik:RadMenu ID="RadMenu2" runat="server"
    <Items> 
        <telerik:RadMenuItem Width="25%" runat="server" Text="Root RadMenuItem1" Value="value1"
            <Items> 
             . . . 
            </Items> 
        </telerik:RadMenuItem> 
 
        <telerik:RadMenuItem Width="25%" runat="server" Text="Root RadMenuItem3" Value="value3"
            <Items> 
                . . . 
                <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 3" Value="value33"
                </telerik:RadMenuItem> 
            </Items> 
        </telerik:RadMenuItem>     
    </Items> 
</telerik:RadMenu> 

javascript:
 
    function getSelected() { 
        var menu = $find("<%= RadMenu2.ClientID %>"); 
        var selectedValue = menu.get_selectedItem().get_value(); // get the selected value 
    } 

You could refer the following links to know more about the most important methods of RadMenu:
Client-Side Basics
RadMenuItem object


-Shinu.
0
Patrick Williams
Top achievements
Rank 1
answered on 26 May 2010, 06:29 PM
Hi Shinu,
Thanks for the speedy response, but i'm still having difficulty getting the value.
On output of the value "menu" in the javascript function I get "[object Object]".
And if i try to alert "menu.id" I get "undefined", and alert of "menu.get_selectedItem().get_value()" I get NO alerts.

However, if i use "document.getElementById("<%= RadMenu1.ClientID %>")" and try to alert "menu.id" then i
get the ID for the control. But trying to get the "menu.get_selectedItem()" seems to not working.

Any other suggestions?


0
Bharadwaj
Top achievements
Rank 1
answered on 22 Sep 2012, 05:31 AM
How to set the width of drop down menu using java script....at runtime
0
Kate
Telerik team
answered on 26 Sep 2012, 03:26 PM
Hello Bharadwaj,

Please refer to the following forum post where it is explained and exemplified how you can set the groupSettings properties of the RadMenu items dynamically using client-side:
http://www.telerik.com/community/forums/aspnet-ajax/menu/radmenu-how-to-set-group-height-on-load-on-demand.aspx#1821855 

Regards,
Kate
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.
Tags
Menu
Asked by
Patrick Williams
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Patrick Williams
Top achievements
Rank 1
Bharadwaj
Top achievements
Rank 1
Kate
Telerik team
Share this question
or