Disable/hide context menu items for specific TimeSlots

4 posts, 0 answers
  1. Raghavendra
    Raghavendra avatar
    6 posts
    Member since:
    Dec 2011

    Posted 10 Jan 2012 Link to this post

    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
  2. Richard
    Richard avatar
    479 posts
    Member since:
    Nov 2011

    Posted 10 Jan 2012 Link to this post

    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.
  3. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 12 Jan 2012 Link to this post

    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
  4. Sac
    Sac avatar
    6 posts
    Member since:
    Jul 2012

    Posted 09 Jan 2013 Link to this post

    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);


Back to Top