Disable TimeSlotContextMenus for a given view

4 posts, 0 answers
  1. Joe Kowalski
    Joe Kowalski avatar
    10 posts
    Member since:
    Jun 2005

    Posted 21 May 2012 Link to this post

    I can't seem to find a simple approach to this.

    I need to completly disable the timeSlotContextMenus for all TimeSlots in the monthly view. Client side or server side, wither will work.
    Thanks
    Joe
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 22 May 2012 Link to this post

    Hello Joe,

    If you are using server binding for RadScheduler the following code should do exactly what you need:
    <telerik:RadScheduler ID="RadScheduler1" runat="server" SelectedView="MonthView"
        TimeSlotContextMenuSettings-EnableDefault="true" OnNavigationComplete="RadScheduler1_NavigationComplete">
    </telerik:RadScheduler>
    protected void RadScheduler1_NavigationComplete(object sender, SchedulerNavigationCompleteEventArgs e)
    {
        if(e.Command == SchedulerNavigationCommand.SwitchToMonthView){
            RadScheduler1.TimeSlotContextMenuSettings.EnableDefault = false;
        }else {
            RadScheduler1.TimeSlotContextMenuSettings.EnableDefault = true;
        }
    }
     
    protected void Page_Load(object sender, EventArgs e)
    {
        if(RadScheduler1.SelectedView == SchedulerViewType.MonthView){
            RadScheduler1.TimeSlotContextMenuSettings.EnableDefault = false;
        }
    }

    All the best,
    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.
  3. Joe Kowalski
    Joe Kowalski avatar
    10 posts
    Member since:
    Jun 2005

    Posted 22 May 2012 Link to this post

    Thank you for you response. This does not apprear to work. We are using custom context menus.

    Perhaps this is a better question: How do I switch context menus? I want to use TimeSlotDidabledContectMenu for monthly and timeline views and SchedulerTimeSlotContextMenu for all other views.

    <TimeSlotContextMenus>
        <telerik:RadSchedulerContextMenu ID="SchedulerTimeSlotContextMenu" runat="server" Skin="Outlook">
            <Items>
                <telerik:RadMenuItem Text=""  />
                <telerik:RadMenuItem IsSeparator="True" />
                <telerik:RadMenuItem Text="New Job"  />
                <telerik:RadMenuItem Text="New Task" />
                <telerik:RadMenuItem IsSeparator="True" />
                <telerik:RadMenuItem Text="Google Route" />
                <telerik:RadMenuItem IsSeparator="True" />
                <telerik:RadMenuItem Text="Go to today" Value="CommandGoToToday" />
                <telerik:RadMenuItem Text="Show 24 hours" Value="CommandShow24Hours" />
            </Items>
        </telerik:RadSchedulerContextMenu>
        <telerik:RadSchedulerContextMenu ID="TimeSlotDidabledContectMenu" runat="server" Skin="Outlook" Enabled="false"></telerik:RadSchedulerContextMenu>
                              
                            </TimeSlotContextMenus>

  4. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 25 May 2012 Link to this post

    Hello Joe,

    If you use server-side binding then the following JavaScript should do the job:
    function pageLoad() {
        var scheduler = $find("<%= RadScheduler1.ClientID%>");
        if (scheduler.get_selectedView() == Telerik.Web.UI.SchedulerViewType.MonthView
            || scheduler.get_selectedView() == Telerik.Web.UI.SchedulerViewType.TimelineView) {
            scheduler.set_timeSlotContextMenuIDs(["TimeSlotDidabledContectMenu"]);
        }
        else {
            scheduler.set_timeSlotContextMenuIDs(["SchedulerTimeSlotContextMenu"]);
        }
    }
    <telerik:RadScheduler ID="RadScheduler1" runat="server" EnableCustomAttributeEditing="true"
        OnTimeSlotCreated="RadScheduler1_TimeSlotCreated" >
        <TimeSlotContextMenus>
            <telerik:RadSchedulerContextMenu ID="SchedulerTimeSlotContextMenu" runat="server"
                Skin="Outlook">
                <Items>
                    <telerik:RadMenuItem Text="" />
                    <telerik:RadMenuItem IsSeparator="True" />
                    <telerik:RadMenuItem Text="New Job" />
                    <telerik:RadMenuItem Text="New Task" />
                    <telerik:RadMenuItem IsSeparator="True" />
                    <telerik:RadMenuItem Text="Google Route" />
                    <telerik:RadMenuItem IsSeparator="True" />
                    <telerik:RadMenuItem Text="Go to today" Value="CommandGoToToday" />
                    <telerik:RadMenuItem Text="Show 24 hours" Value="CommandShow24Hours" />
                </Items>
            </telerik:RadSchedulerContextMenu>
            <telerik:RadSchedulerContextMenu ID="TimeSlotDidabledContectMenu" runat="server"
                Skin="Outlook" Enabled="false">
                <Items>
                    <telerik:RadMenuItem Text="item1" />
                    <telerik:RadMenuItem Text="item2" />
                    <telerik:RadMenuItem Text="item3" />
                </Items>
            </telerik:RadSchedulerContextMenu>
        </TimeSlotContextMenus>
    </telerik:RadScheduler>

    If you are using web service binding to populate RadScheduler with data then you need to handle the NavigationComplete client event so you will be able to change the context menu when the selected view changes as here no postback to the server will be made when selected view is changed.

    Kind 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.
Back to Top