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

Disable TimeSlotContextMenus for a given view

3 Answers 72 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Joe Kowalski
Top achievements
Rank 1
Joe Kowalski asked on 21 May 2012, 07:37 PM
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

3 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 22 May 2012, 03:23 PM
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.
0
Joe Kowalski
Top achievements
Rank 1
answered on 22 May 2012, 09:35 PM
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>

0
Ivana
Telerik team
answered on 25 May 2012, 05:54 PM
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.
Tags
Scheduler
Asked by
Joe Kowalski
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Joe Kowalski
Top achievements
Rank 1
Share this question
or