Is there any way to create an AppointmentCollection and manually fill with Appointment objects, along the lines of:
Create new AppointmentCollection
Grab Appointments from database
Loop through, add new Appointment objects to AppointmentCollection
Call AppointmentCollection.GetAppointmentsInRange
Currently I am doing this, but there must be an easier way to do without having to use a RadScheduler.
// Check for a conflict |
var appointments = dc.Appointments.Select(b => b.IsCancelled == false); |
RadScheduler scheduler = new RadScheduler(); |
scheduler.DataKeyField = "AppointmentID"; |
scheduler.DataSubjectField = "Subject"; |
scheduler.DataStartField = "Start"; |
scheduler.DataEndField = "End"; |
scheduler.DataRecurrenceField = "RecurrenceRule"; |
scheduler.DataRecurrenceParentKeyField = "RecurrenceParentID"; |
scheduler.DataSource = appointments; |
scheduler.DataBind(); |
return scheduler.Appointments.GetAppointmentsInRange(startTime, endTime).Count == 0; |
Cheers,
Mike
10 Answers, 1 is accepted
0
Hi Mike,
Please, refer to the Binding to generic list demo:
http://demos.telerik.com/aspnet-ajax/scheduler/examples/bindtolist/defaultcs.aspx
Appointments are initialized like this:
Please, feel free to contact us if you need further assistance.
Best wishes,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Please, refer to the Binding to generic list demo:
http://demos.telerik.com/aspnet-ajax/scheduler/examples/bindtolist/defaultcs.aspx
Appointments are initialized like this:
private void InitializeAppointments() |
{ |
DateTime start = DateTime.UtcNow.Date; |
start = start.AddHours(6); |
Appointments.Add(new AppointmentInfo("Take the car to the service", start, start.AddHours(1), string.Empty, null, 1)); |
Appointments.Add(new AppointmentInfo("Meeting with Alex", start.AddHours(2), start.AddHours(3), string.Empty, null, 2)); |
start = start.AddDays(-1); |
DateTime dayStart = RadScheduler1.UtcDayStart(start); |
Appointments.Add(new AppointmentInfo("Bob's Birthday", dayStart, dayStart.AddDays(1), string.Empty, null, 1)); |
Appointments.Add(new AppointmentInfo("Call Charlie about the Project", start.AddHours(2), start.AddHours(3), string.Empty, null, 2)); |
start = start.AddDays(2); |
Appointments.Add(new AppointmentInfo("Get the car from the service", start.AddHours(2), start.AddHours(3), string.Empty, null, 1)); |
} |
Please, feel free to contact us if you need further assistance.
Best wishes,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Mike
Top achievements
Rank 2
answered on 07 Aug 2009, 03:15 PM
Yes, that would work if I just wanted a generic list of appointments.
However, I need to use the AppointmentCollection object, I would like to be able to call AppointmentCollection.GetAppointmentsInRange
I can't call this method on a generic list.
However, I need to use the AppointmentCollection object, I would like to be able to call AppointmentCollection.GetAppointmentsInRange
I can't call this method on a generic list.
0
Hi Mike,
The Add method is not exposed for the AppointmentCollection, but you can add appointments anyway like this:
Best wishes,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
The Add method is not exposed for the AppointmentCollection, but you can add appointments anyway like this:
* * * |
AppointmentCollection apts = new AppointmentCollection(); |
((IList<Appointment>) apts).Add(new Appointment(1, DateTime.Now, DateTime.Now.AddHours(1), "Test")); |
* * * |
Best wishes,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Mike
Top achievements
Rank 2
answered on 11 Aug 2009, 02:17 PM
This code does compile and builds successfully,
Unfortunately it throws the following error at runtime: Unable to cast object of type 'Telerik.Web.UI.AppointmentCollection' to type 'System.Collections.Generic.IList`1[Telerik.Web.UI.Appointment]'.
I am running version 2009.1.311.35 of the Telerik DLL. I really appreciate all your help!
AppointmentCollection apts = new AppointmentCollection(); |
((IList<Appointment>)apts).Add(new Appointment(1, DateTime.Now, DateTime.Now.AddHours(1), "Test")); |
Unfortunately it throws the following error at runtime: Unable to cast object of type 'Telerik.Web.UI.AppointmentCollection' to type 'System.Collections.Generic.IList`1[Telerik.Web.UI.Appointment]'.
I am running version 2009.1.311.35 of the Telerik DLL. I really appreciate all your help!
0
Accepted
Sorry, I have mislead you. The code should be like this:
using System.Collections; |
/* * * |
AppointmentCollection apts = new AppointmentCollection(); |
((IList)apts).Add(new Appointment(1, DateTime.Now, DateTime.Now.AddHours(1), "Test")); |
Greetings,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Mike
Top achievements
Rank 2
answered on 11 Aug 2009, 03:27 PM
Success! I appreciate your help Peter.
Thanks.
Thanks.
0

Steven
Top achievements
Rank 1
answered on 02 Aug 2012, 09:49 PM
I am binding to a generic list like the demo shows. The demo uses its own appointment object, AppointmentInfo. I'm using my own object which I call ProductionRun. I have everything running smoothly. The only issue is I'd like to be able to use the GetAppointmentsInRange to search my list of ProcuctionRun objects. How can I do this? AppointmentCollection only takes Appointment objects, correct?
0
Hello Steven,
Indeed, the GetAppointmentsInRange method returns a list of appointment objects only. I am not sure what you are trying to achieve, but basically, you can convert your custom class objects from code to appointment objects, using one of the Appointment constructors. For example:
Regards,
Peter
the Telerik team
Indeed, the GetAppointmentsInRange method returns a list of appointment objects only. I am not sure what you are trying to achieve, but basically, you can convert your custom class objects from code to appointment objects, using one of the Appointment constructors. For example:
IList<Appointment> appList =
new
IList<Appointment>();
appList.Add(
new
Appointment(1, DateTime.Now, DateTime.Now.AddDays(1),
"test"
));
Regards,
Peter
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

Arul
Top achievements
Rank 1
answered on 30 Oct 2012, 10:19 PM
The following piece of code puts both the appointment in the same date and time . How do i insert two appointments to the RadScheduler
meetingAppointment.Subject = "Test";
meetingAppointment.Start = DateTime.Now;
meetingAppointment.End = DateTime.Now;
RadScheduler1.InsertAppointment(meetingAppointment);
TimeSpan ts = new TimeSpan(0, 12, 0, 0);
meetingAppointment.Subject = "Test2";
meetingAppointment.Start = DateTime.Now + ts;
meetingAppointment.End = DateTime.Now + ts;
RadScheduler1.InsertAppointment(meetingAppointment);
meetingAppointment.Subject = "Test";
meetingAppointment.Start = DateTime.Now;
meetingAppointment.End = DateTime.Now;
RadScheduler1.InsertAppointment(meetingAppointment);
TimeSpan ts = new TimeSpan(0, 12, 0, 0);
meetingAppointment.Subject = "Test2";
meetingAppointment.Start = DateTime.Now + ts;
meetingAppointment.End = DateTime.Now + ts;
RadScheduler1.InsertAppointment(meetingAppointment);
0
Hello Arul,
Plamen
the Telerik team
If you want to add more than one appointment to RadScheduler you should add them to the DataSource and rebind because InsertAppointment is working properly with only one appointment at a time.
Hope this will explain the issue.
Plamen
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.