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

[Solved] How to disable the context menus

8 Answers 483 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
sabarishbabu
Top achievements
Rank 1
sabarishbabu asked on 15 Sep 2009, 07:01 AM
hi,

i am using context menus(4 options) for showing right click options.but am not able to implement some of the things  that are follows

These are to be done in server side.because i have some validations in server side to show/hide content menus.

1.  I need to disable the right click options(context menus) for  particular appointment.
2.  I need to enable one context menu out of 4 menus for particular appointment


how can it is possible?

Thanks for your valuable suggestions,

Sabarish

8 Answers, 1 is accepted

Sort by
0
Samir Patel
Top achievements
Rank 1
answered on 15 Sep 2009, 01:58 PM
I also created seperate thread for this question before 15 days...

Please gives us the answer of it...

REgards
Samir
0
Peter
Telerik team
answered on 16 Sep 2009, 12:57 PM
Hello,

1. Please, refer to this online demo:
http://demos.telerik.com/aspnet-ajax/scheduler/examples/contextmenu/defaultcs.aspx

In the OnClientAppointmentContextMenu handler, simply do not call the show method of the menu for a particular appointment:
 function appointmentContextMenu(sender, eventArgs)  
                {  
                    var menu = $find("<%= SchedulerAppointmentContextMenu.ClientID %>");  
                    selectedAppointment = eventArgs.get_appointment();  
                    checkResourceMenuItem(menu, selectedAppointment);  
                    menu.show(eventArgs.get_domEvent());  
                }  
 

2. Handler OnClientShowing for RadContext menu and use the client API of the control to disable items for a given appointemnt. Here is an online demo for reference:
http://demos.telerik.com/aspnet-ajax/menu/examples/programming/addremovedisableitemsclientside/defaultcs.aspx


Greetings,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
sabarishbabu
Top achievements
Rank 1
answered on 17 Sep 2009, 10:44 AM
Thanks for your replies

but i want the code in server side.In client side, i cant do some server side validations.

i have to block the user to  edit/delete/rightclickoptions for other user's appointments

in  radschedular1_AppointmentDataBound,am getting selected appointment id, so i can get the userid  for selected appointmentid.Then i am matching with the login userid.If it is not matching, does not allow the user to edit/delete and should disable the context menus.

i can disable the Edit and delete as follows.As same as these, i want to disable the context menus.         
                    if (apptUserId != loginUserId)
                    {
                        e.Appointment.AllowDelete = false;                       
                        e.Appointment.AllowEdit = false;  
                    }

and also   I need to enable one context menu out of 4 menus for particular appointment in server side
Thanks for your valuable suggestions
0
Peter
Telerik team
answered on 18 Sep 2009, 12:08 PM
Hi sabarishbabu,

You can set custom attributes in AppointmentDataBound and then access the values of these attributes in the OnClientAppointmentContextMenu handler and show a specific menu or not show any menu at all depending on the values of the custom attributes. For example:

 protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)  
        {  
            if ([CustomCondition])  
            {  
                e.Appointment.Attributes["DisableMenu"] = "true";  
            }  
        } 

function appointmentContextMenu(sender, eventArgs)  
                {  
                    if (eventArgs.get_appointment().get_attributes().getAttribute("DisableMenu") != "true") {  
 
                        var menu = $find("<%= SchedulerAppointmentContextMenu.ClientID %>");  
                        selectedAppointment = eventArgs.get_appointment();  
                        checkResourceMenuItem(menu, selectedAppointment);  
                        menu.show(eventArgs.get_domEvent());  
                    }  
                      
                }  
             



Greetings,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Colibri
Top achievements
Rank 1
answered on 24 Nov 2009, 03:24 PM
Hi,

I don't understand why but, I'm trying to do exactly the same:
I want to display the ContextMenu only if attribute "ShowMenu" is set to true

            function appointmentContextMenu(sender, eventArgs) { 
                if (eventArgs.get_appointment().get_attributes().getAttribute("ShowMenu") == "True") { 
                    var menu = $find("<%= SchedulerAppointmentContextMenu.ClientID %>"); 
                    selectedAppointment = eventArgs.get_appointment(); 
                    menu.show(eventArgs.get_domEvent());             
                }
            }

This code works great but for some reason, the menu still appear.

Thanks
0
Peter
Telerik team
answered on 24 Nov 2009, 04:18 PM
Hi Colibri,

I am not sure why the code does not work in your case,  but I suggest you take advantage of the built-in context menus that we have introduced with the Q3 2009 release.

http://www.telerik.com/help/aspnet-ajax/scheduler-appointment-context-menu.html

http://www.telerik.com/help/aspnet-ajax/scheduler-timeslot-context-menu.html


With the latest build we have also added disabling the context menu for specific appointments. Now you can simply set ContextMenuID to a non existing ID and no menu will be shown for that appointment. For example, in AppointmentDataBound you can try: e.Appointment.ContextMenuID = "none";

Should you have further questions - feel free to contact us.


Best wishes,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Colibri
Top achievements
Rank 1
answered on 24 Nov 2009, 05:20 PM
I am not sure why the code does not work in your case,  but I suggest you take advantage of the built-in context menus that we have  introduced with the Q3 2009 release.

>> I'm using the built-in context menus of the Q3 2009 release

More context, this is my scheduler
<trik:RadScheduler runat="server" ID="scheduler"
        DataStartField="Start" 
        DataEndField="End" DataKeyField="Id" DataSubjectField="Title" 
        AdvancedForm-EnableCustomAttributeEditing="true"  
        CustomAttributeNames="CanImport,EwsId" 
        OnAppointmentDataBound="SchedulerAppointmentDataBound"
        OnClientAppointmentContextMenu="appointmentContextMenu">               
        <AppointmentContextMenus> 
            <trik:RadSchedulerContextMenu runat="server" ID="SchedulerAppointmentContextMenu"  
            ExpandAnimation-Type="None" CollapseAnimation-Type="None"
                <Items> 
                    <trik:RadMenuItem Text="Import" Value="Import"/> 
                </Items> 
            </trik:RadSchedulerContextMenu> 
        </AppointmentContextMenus>               
    </trik:RadScheduler> 

The client side function
<script type="text/javascript"
        var selectedAppointment = null
        function appointmentContextMenu(sender, eventArgs) { 
            var canImport = eventArgs.get_appointment().get_attributes().getAttribute("CanImport");
            if (canImport == "True") { 
                alert('display menu');
                var menu = $find("<%= SchedulerAppointmentContextMenu.ClientID %>"); 
                selectedAppointment = eventArgs.get_appointment(); 
                menu.show(eventArgs.get_domEvent());             
            } 
        } 
    </script> 

So I get the js alert 'display menu' when canImport is set to true. But, menu still apear if I don't have the alert.

I also try to add your code in the AppointmentDataBound. It doesn't change anything.
protected void SchedulerAppointmentDataBound(object sender, SchedulerEventArgs e) { 
 
            if (e.Appointment.DataItem is ICalendarViewable) { 
                if (ev.CanImport) { 
                    e.Appointment.ContextMenuID = SchedulerAppointmentContextMenu.ClientID; 
                } else { 
                    e.Appointment.ContextMenuID = "none"
                } 
            } 
        } 

Am I doing something wrong ?

Thanks
0
Peter
Telerik team
answered on 25 Nov 2009, 02:37 PM
Hi Blaise,

To use the approach for disabling the built-in context menu for specific appointments, you need to use the latest build. I am sorry for not making this part stand out more prominently.

"With the latest build we have also added disabling the context menu for specific appointments. Now you can simply set ContextMenuID to a non existing ID and no menu will be shown for that appointment."


Regards,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Scheduler
Asked by
sabarishbabu
Top achievements
Rank 1
Answers by
Samir Patel
Top achievements
Rank 1
Peter
Telerik team
sabarishbabu
Top achievements
Rank 1
Colibri
Top achievements
Rank 1
Share this question
or