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

Disable/hide context menu items for specific TimeSlots

3 Answers 256 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Raghavendra
Top achievements
Rank 1
Raghavendra asked on 10 Jan 2012, 12:53 PM
Hi,

I want to disable/hide the New Appointment and New Recurring Appointment context menu items when the user right clicks on a TimeSlot which occurs in the past (i.e., date value is lesser than current system date time).

At first, I thought the obvious place to put such functionality would be to handle OnClientTimeSlotContextMenu event of the scheduler. So, I added an event handler and it is firing properly. But now, I am clueless as to what method to call to achieve this functionality.

Thanks in advance,
Raghu

3 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 10 Jan 2012, 05:45 PM
Raghavendra:

Have you reviewed the Appointment context menu documentation page for the RadScheduler? It provides insights on the setting that you need to manipulate, based on validity of the appointment's date.

You could validate the date on the OnClientAppointmentContextMenuItemClicking event, which allows for the event to be canceled.

Hope this helps.
0
Ivana
Telerik team
answered on 12 Jan 2012, 05:17 PM
Hello,

You could subscribe to the OnClientTimeSlotContextMenu event and manipulate the context menu's items from within its handler, as shown in the following example:
function OnClientTimeSlotContextMenu(sender, args) {
    var date = new Date();
    if (args.get_time() < date) {
        $find("RadScheduler1_SchedulerAppointmentContextMenu").get_items().getItem(0).set_enabled(false);
    } else {
        $find("RadScheduler1_SchedulerAppointmentContextMenu").get_items().getItem(0).set_enabled(true);
    }
}
<telerik:RadScheduler runat="server" ID="RadScheduler1" OnClientTimeSlotContextMenu="OnClientTimeSlotContextMenu"
    SelectedView="WeekView">
    <TimeSlotContextMenus>
        <telerik:RadSchedulerContextMenu ID="SchedulerAppointmentContextMenu" runat="server">
            <Items>
                <telerik:RadMenuItem Text="Option 1" Value="1">
                    <Items>
                        <telerik:RadMenuItem Text="Option 1.1 " Value="1.2" />
                    </Items>
                </telerik:RadMenuItem>
                <telerik:RadMenuItem Text="Option 2" Value="2">
                </telerik:RadMenuItem>
                <telerik:RadMenuItem IsSeparator="True" />
                <telerik:RadMenuItem Text="Option 3" Value="3" />
            </Items>
        </telerik:RadSchedulerContextMenu>
    </TimeSlotContextMenus>
</telerik:RadScheduler>

I hope this would be helpful.

Regards,
Ivana
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
0
Sac
Top achievements
Rank 1
answered on 09 Jan 2013, 08:06 AM
Thanks...

It really very helpful to me and save my time too.

I just want to add that some time we need to use
$find("<%=ContextMenu1.ClientID %>").get_items().getItem(0).set_enabled(false);

instead of

$find("RadScheduler1_ContextMenu1").get_items().getItem(0).set_enabled(false);


Tags
Scheduler
Asked by
Raghavendra
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Ivana
Telerik team
Sac
Top achievements
Rank 1
Share this question
or