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

AppointmentCreatingEventArgs.Appointment is read-only

4 Answers 100 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
hwsoderlund
Top achievements
Rank 1
hwsoderlund asked on 19 Jan 2011, 09:47 AM
I have hooked up to the AppointmentCreating event, and am trying to insert my own custom object into the Appointment property of the AppointmentCreatingEventArgs class (this is something that we could do in RadScheduler). But that property does not have a "set" accessor. This means that I have to map all the properties of my appointment object to the appointment sitting in the eventargs object. This requires a lot of, in my opinion unnecessary, code. It will also be quite error-prone since that code has to be checked and updated each time a change is made to the class (I am using my own, custom appointment class that derives from Appointment, with a lot of extra properties). Is there any chance that you could add a "set" accessor to the AppointmentCreatingEventArgs class?

4 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 19 Jan 2011, 10:07 AM
Hi Henrik,

If the main idea is to force RadScheduleView to "create" appointments of different type than Appointment, the better approach is to use different source collection:

var appointmentsSource = new ObservableCollection<MyAppointment>();
...
scheduleView.AppointmentsSource = appointmentsSource;
(this will work in XAML too)

This way RadScheduleView will automatically create objects of type MyAppointment when you double click in an empty slot. Recently we published a blog post about custom appointments that might be of help:
http://blogs.telerik.com/miroslavnedyalkov/posts/10-11-25/how_to_create_custom_appointments_and_custom_appointment_dialog_in_telerik_scheduleview.aspx

The purpose of the AppointmentCreating event is to initialize the new appointments with some predefined values, if you want some specific title for example, you could set it in the handler. In addition, if you use the typed observable collection above, the object in the Appointment property of the event args will be of MyAppointment type.

All the best,
Valeri Hristov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
hwsoderlund
Top achievements
Rank 1
answered on 19 Jan 2011, 10:17 AM
Yes, I realize all that. It all makes sense. :) But my problem is that I have to get the appointment object to be inserted from the service. It is a fairly complex scenario. I will try to explain some of it:
  • We have different types of events. These are mapped against the built-in Categories in the RadScheduleView. This is to get the automatic coloring of the different types of events.
  • All the different types of events (they could be things like Workshop, Classroom Session, Online Meeting, Pub Night, anything our clients want, it is all configurable) have custom fields attached to them. For instance, a Classroom Session could have a field named "Classroom Location". An Online Meeting could have fields like "Login URL". Again, all configurable.
  • On the client side, I have no way of telling which custom fields should be set up for each new event created. I have to make a service call (the method is GetNewCalendarEvent(int eventTypeID) ), get a result, create a new Appointment object, or actually GLSAppointment, as my class is named, and insert it as the object being edited in the RadScheduleView appointment editor.
  • While I realize that it is possible to just map all these object properties manually, it  is a lot of hassle. It would be so much easier if I could just overwrite the entire object. 
I hope that gives you a better idea of why I am requesting this feature.
0
Accepted
Valeri Hristov
Telerik team
answered on 19 Jan 2011, 10:30 AM
You can try with this:
var serviceAppointment = service.GetNewAppointment();
e.Appointment.CopyFrom(serviceAppointment);

Note that in order to allow RadScheduleView to work properly with the custom appointments you need to override the Copy and CopyFrom methods anyway.

Best wishes,
Valeri Hristov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
hwsoderlund
Top achievements
Rank 1
answered on 19 Jan 2011, 11:23 AM
Ah, nice. I did not know that. I'll try it.
Tags
ScheduleView
Asked by
hwsoderlund
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
hwsoderlund
Top achievements
Rank 1
Share this question
or