Enable and disable item child radmenu

4 posts, 0 answers
  1. Fabio Cirillo
    Fabio Cirillo avatar
    180 posts
    Member since:
    Jan 2010

    Posted 24 Jan 2013 Link to this post

    hi,
    i need enable and disable the item child of the radmenu depending on the data taken from a database.
    For example...
    into page aspx into page_load event or page_init, if there're not the record into database the item child witn value 2 must be disable.

    this code radmanu is:
    <telerik:RadMenu ID="RadMenu1" Runat="server"
    EnableRoundedCorners="True" EnableShadows="True" Skin="Sunset">
    <Items>
    <telerik:RadMenuItem runat="server" Owner="RadMenu1" Text="Immagine profilo">
    <Items>
    <telerik:RadMenuItem runat="server" ImageUrl="~/Image/Icone/new.png" Owner=""
    Text="Nuova" Width="110px" Value="1">
    </telerik:RadMenuItem>
    <telerik:RadMenuItem runat="server" ImageUrl="~/Image/Icone/view.png" Owner=""
    Text="Visualizza" Width="110px" Value="2">
    </telerik:RadMenuItem>
    <telerik:RadMenuItem runat="server" ImageUrl="~/Image/Icone/delete.png"
    Owner="" Text="Elimina" Width="110px" Value="3">
    </telerik:RadMenuItem>
    </Items>
    </telerik:RadMenuItem>
    </telerik:RadMenu>

    how can i do it? with client side and use javascript or server side and use codce behind?
    i use this code:

    RadMenu1.Items(0).Items(1).Enabled = false

    but into load event dont fuction. this code function only radmenu1_init event. But i must need that function in page_load event because there i load the record from database

     

    Second problem i use the radwindows for load a new page and into this i save the record. When i close the radwindows, the item child with value 2 must be enable. So must tu use the javascript code?

    Please help me

    thanks you

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Jan 2013 Link to this post

    Hi Fabio

    The best option that I would suggest is to attach the OnClientLoad event and try disabling the menu item from javascript
    aspx
    <telerik:RadMenu ID="RadMenu1" runat="server" EnableRoundedCorners="True" EnableShadows="True"
     OnClientLoad="OnClientLoad"Skin="Sunset">
              
    JS
    <script type="text/javascript">
    function OnClientLoad(sender, args)
    {
      var menu = $find("<%= RadMenu1.ClientID %>");
      var menuItem = menu.findItemByValue("2");
      menuItem.disable();
    }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. suren
    suren avatar
    1 posts
    Member since:
    Sep 2016

    Posted 16 Sep in reply to Princy Link to this post

    Hi Princy

    Is not working for me 

  5. Anton
    Admin
    Anton avatar
    61 posts

    Posted 20 Sep Link to this post

    Hi Suren,

    OnClientLoad  is a client-side function that by design accepts one parameter. You can find more info here. Take a look at the working example below:

    <telerik:RadScriptManager runat="server"></telerik:RadScriptManager>
            <div>
                <telerik:RadMenu ID="RadMenu1" runat="server" EnableRoundedCorners="True" EnableShadows="True" Skin="Sunset" OnClientLoad="onClientLoad">
                    <Items>
                        <telerik:RadMenuItem runat="server" Owner="RadMenu1" Text="Immagine profilo">
                            <Items>
                                <telerik:RadMenuItem runat="server" Owner=""
                                    Text="Nuova" Width="110px" Value="1">
                                </telerik:RadMenuItem>
                                <telerik:RadMenuItem runat="server" Owner=""
                                    Text="Visualizza" Width="110px" Value="2">
                                </telerik:RadMenuItem>
                                <telerik:RadMenuItem runat="server" Owner="" Text="Elimina" Width="110px" Value="3">
                                </telerik:RadMenuItem>
                            </Items>
                        </telerik:RadMenuItem>
                    </Items>
                </telerik:RadMenu>
            </div>
        </form>
        <script>
            var menu;
     
            function onClientLoad(sender) {
                menu = sender;
     
                var menuItem = menu.findItemByValue("2");
                menuItem.disable();
            }
        </script>


    Regards,
    Anton
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top