How to with RadMenu And Javascipt

5 posts, 0 answers
  1. Patrick Williams
    Patrick Williams avatar
    8 posts
    Member since:
    Aug 2009

    Posted 21 May 2010 Link to this post

    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. 
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 May 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Patrick Williams
    Patrick Williams avatar
    8 posts
    Member since:
    Aug 2009

    Posted 26 May 2010 Link to this post

    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?


  5. Bharadwaj
    Bharadwaj avatar
    3 posts
    Member since:
    Sep 2012

    Posted 22 Sep 2012 Link to this post

    How to set the width of drop down menu using java script....at runtime
  6. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 26 Sep 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017