Telerik RadScheduler Bind to SQL Server With Different Resource

来源:互联网 发布:vmware linux上网设置 编辑:程序博客网 时间:2024/04/19 14:23

Code Overview:

<telerik:RadSplitBar runat="server" ID="RadSplitBar2" CollapseMode="Forward" />            <telerik:RadPane runat="Server" ID="rightPane" Scrolling="None" Width="615px">                <telerik:RadScheduler runat="server" ID="RadScheduler1" Skin="Windows7" Height="551px"                    ShowFooter="False" SelectedDate="2009-02-02" TimeZoneOffset="00:00:00"                    DayEndTime="21:00:00" FirstDayOfWeek="Monday" LastDayOfWeek="Friday"                    AppointmentStyleMode="Default" OnNavigationComplete="RadScheduler1_NavigationComplete"                    OnAppointmentCreated="RadScheduler1_AppointmentCreated" OnAppointmentDataBound="RadScheduler1_AppointmentDataBound"                    OnAppointmentDelete="RadScheduler1_AppointmentDelete" OnAppointmentUpdate="RadScheduler1_AppointmentUpdate"                    OnAppointmentInsert="RadScheduler1_AppointmentInsert"                     DataEndField="End" DataKeyField="Id"                     DataSourceID="EntityDataSource1" DataStartField="Start"                     DataSubjectField="Subject">                    <AdvancedForm Modal="true" />                    <TimelineView UserSelectable="false" />                    <ResourceTypes>                        <telerik:ResourceType KeyField="Id" Name="Room" TextField="Description"                         ForeignKeyField="TestResourceId"                            DataSourceID="EntityDataSource2" />                    </ResourceTypes>                    <ResourceStyles>                         <telerik:ResourceStyleMapping Type="Room" Text="resource A" BackColor="Blue" />                         <telerik:ResourceStyleMapping Type="Room" Text="resource B" BackColor="Orange" />                         <telerik:ResourceStyleMapping Type="Room" Text="resource A" ApplyCssClass="rsCategoryGreen" />                    </ResourceStyles>                    <AppointmentTemplate>                        <div class="rsAptSubject">                            <%# Eval("Subject") %>                        </div>                        <%# Eval("Description") %>                    </AppointmentTemplate>                    <TimeSlotContextMenuSettings EnableDefault="true" />                    <AppointmentContextMenuSettings EnableDefault="true" />                </telerik:RadScheduler>                                <asp:EntityDataSource ID="EntityDataSource1" runat="server"                     ConnectionString="name=IAppointmentEntities"                     DefaultContainerName="IAppointmentEntities" EnableFlattening="False"                     EntitySetName="Appointments">                </asp:EntityDataSource>                <asp:EntityDataSource ID="EntityDataSource2" runat="server"                     ConnectionString="name=IAppointmentEntities"                     DefaultContainerName="IAppointmentEntities" EnableFlattening="False"                     EntitySetName="TestResources">                </asp:EntityDataSource>                            </telerik:RadPane>        </telerik:RadSplitter>

Two Tables Structure


Sample Data

Appointments

ID Subject Description StartEndRecurrenceRuleRecurrenceParentIDReminderAnnotationsTestResourceId
1 .NET User Group MeetingNULL2011-11-14 12:00:00.0002011-11-15 12:00:00.000NULLNULLNULLNULL1
2 Scrum TrainingNULL2011-11-13 12:00:00.0002011-11-15 12:00:00.000NULLNULLNULLNULL1
3 Integration Partners Conference CallNULL2011-11-12 12:00:00.0002011-11-15 12:00:00.000NULLNULLNULLNULL2
4 DevConnect conferenceNULL2011-11-11 12:00:00.0002011-11-15 12:00:00.000NULLNULLNULLNULL2
5 DevMedia conferenceNULL2011-11-10 12:00:00.0002011-11-15 12:00:00.000NULLNULLNULLNULL1

TestResources

Id Description
1 resource A
2 resource B
3 resource C
4 resource D
5 resource E


Note (Enhancement): here is sample data for RecurrenceRule

DTSTART:20070330T063000Z  DTEND:20070330T073000Z  RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20070406T210000Z;BYDAY=MO,TU,WE,TH,FR; 

DTSTART:20080218T000000Z 
DTEND:20080219T000000Z 
RRULE:FREQ=MONTHLY;INTERVAL=12;BYDAY=-2MO;COUNT=3;

 

This rule says: "The event starts at midnight on 18th of February 2008, lasts one day and repeats each year, for 3 years, on the second to last Monday of February". Now say this three times fast.

RecurrencePattern - This is the pattern that the appointment recurs by, whether it's on an hourly, daily, etc. basis (frequency), the day(s) of the week to recur on (DayOfWeekMask), the number of times to separate recurrence appointments by (every 2 weeks, every 5 days, etc.,which is the Interval), and several more factors.

RadScheduler currently uses either the DaysOfWeekMask or the Interval property of the DailyRecurrenceRule,e.g: .DaysOfWeekMask = Telerik.Web.UI.RecurrenceDay.WeekDays

Good Resource: http://dotnetslackers.com/articles/aspnet/Using-Teleriks-Scheduler-Component.aspx

http://dotnetslackers.com/articles/aspnet/Understanding-Teleriks-Scheduler-Recurrence.aspx

http://blogs.telerik.com/aspnet-ajax/posts/08-08-04/working-with-radscheduler-recurring-appointments-on-sql-server.aspx

Resource Style:

http://www.telerik.com/help/aspnet-ajax/scheduler-appearance-setting-appointment-style.html