AppointmentCreatingEventArgs.Appointment is read-only

5 posts, 1 answers
  1. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 19 Jan 2011 Link to this post

    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?
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 19 Jan 2011 Link to this post

    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>>
  3. DevCraft banner
  4. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 19 Jan 2011 Link to this post

    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.
  5. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 19 Jan 2011 Link to this post

    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>>
  6. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 19 Jan 2011 Link to this post

    Ah, nice. I did not know that. I'll try it.
Back to Top
DevCraft banner