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

Custom Appointment Subclass

3 Answers 70 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Eve Cunning
Top achievements
Rank 1
Eve Cunning asked on 26 Feb 2010, 06:28 PM
Hello,

I've spent the past few days trying to subclass Appointment to add additional data properties to it, but to no avail.  (We need to add a dynamic list of string int pairs to the Appointment, which, since they are dynamic, can't be done with the standard declarative attributes set).

So, on my subclass, I overrode Clone, the deserialization constructor and GetObjectData, LoadViewState, and SaveViewState, and created an appropriate AppointmentFactory for the scheduler to use.  However, my additional data values were never making it back to the Insert or Update call on my provider.

Having a look at the code using Reflector, I see that my values are likely getting lost during the internal call to LoadFromDictionary.  There are no virtual functions there for me to inject my data values into the load, so they are never getting restored.

So, just for my own sanity, I wanted to confirm that yes, given the way Scheduler is currently written, subclassing Appointment in this way is impossible, and it's okay to stop trying to make this work.  :)

I am going to fall back and use one of the standard attributes as a delimited string of the values, but I was hoping for the more elegant solution.

Best regards,
Eve

3 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 02 Mar 2010, 12:58 PM
Hello Eve,

I've tested this scenario and the only problem I see is that the base ISerializable implementation does not process the properties in the inherited implementation. To make things worse,  the GetObjectData method is implemented explicitly. Serializing custom fields thus requires completely rewriting it.

So, we've changed two things in the latest internal build:
  1. Appointment ISerializable implementation now processes properties in inherited classes
  2. The GetObjectData is now a protected virtual method

I'm sending you a sample project (with the latest assembly version) that demonstrates that using dictionaries is now easily doable.

We'll consider if the LoadFromDictionary method should be made virtual too, but for this scenario this is not a problem.

I hope this helps.

Kind regards,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Eve Cunning
Top achievements
Rank 1
answered on 02 Mar 2010, 01:31 PM
Thank you, Tsvetomir!  This is perfect.

It was a long journey to try to get the custom subclass to work, then only to find that it would never work.  I am so glad to get this fix!

Best regards,
Eve
0
Jeff
Top achievements
Rank 1
answered on 16 May 2012, 12:16 AM
@Tsvetomir  

Would we be able to do something similar with a WCF Web Service datasource and custom provider?


Tags
Scheduler
Asked by
Eve Cunning
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Eve Cunning
Top achievements
Rank 1
Jeff
Top achievements
Rank 1
Share this question
or