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

Enable and disable item child radmenu

3 Answers 317 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Fabio Cirillo
Top achievements
Rank 1
Fabio Cirillo asked on 24 Jan 2013, 11:12 AM
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

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Jan 2013, 07:52 AM
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.
0
suren
Top achievements
Rank 1
answered on 16 Sep 2016, 12:18 PM

Hi Princy

Is not working for me 

0
Anton
Telerik team
answered on 20 Sep 2016, 06:51 AM
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.
Tags
Menu
Asked by
Fabio Cirillo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
suren
Top achievements
Rank 1
Anton
Telerik team
Share this question
or