I want to extend the data structure of an appointment. I have additional information (objects) which I need on every appointment.
Could anybody help me?
mrfu said: I want to extend the data structure of an appointment. I have additional information (objects) which I need on every appointment.
If you want to subclass the Appointment class, read Extending Appointments and Resources. This is only enough to get you started, but if you follow its rules then the data provider infrastructure can help you if you ever decide to Subclass a Custom Data Provider from the WebScheduleDataProviderBase class. For example, if you're using SQL Server and the stored procedures. If not, then none of the following indented explanation will apply to you.
Taking this path, you'd have to create a subclass of Infragistics.WebUI.Data.AppointmentBinding that serves as a Data Peer for your Appointment subclass. On this Data Peer add a -Member property corresponding to each new property, annotate each of those -Member properties with a WebScheduleDataBindingAttribute, and override its UnderlyingType property to return your subclassed Appointment Type, and its CreateInstance factory method to instantiate an empty instance of your subclassed Appointment Type. On your custom data provider subclass you override the InitializeAppointmentBindings method to return an instance of your AppointmentBinding-subclass to be used by the AppointmentBinding property, so your data bindings and factory method are available when the infrastructure needs access to it. The benefits of this wiring these classes up, is you can call AddCustomParameter in your custom data provider subclass to specify additional stored proc parameters you want passed to SQL Server (it goes without saying the stored procs need to have been modified with columns for your extra properties). Additionally, the infrastructure seamlessly handles mapping values/types in the result set onto a new instance of your Appointment subclass (created with that CreateInstance factory method) when everything is read in. It is the instructions annotated earlier using the WebScheduleDataBindingAttribute that drives this. I should note it only supports binding primitive value types, so it won't map BLOBs and XML sent back in a result set. If you have additional properties which are complex, then you will need to handle the InitializeActivity event which happens after data binding to make the follow-up calls to your database and override the AddActivity(AddActivityContext) and UpdateActivity(UpdateActivityContext) methods first by calling the base method, and then adding additional code for any additional data operations your new properties require that fall outside the purlieu of what the infrastructure handles.
Taking this path, you'd have to create a subclass of Infragistics.WebUI.Data.AppointmentBinding that serves as a Data Peer for your Appointment subclass. On this Data Peer add a -Member property corresponding to each new property, annotate each of those -Member properties with a WebScheduleDataBindingAttribute, and override its UnderlyingType property to return your subclassed Appointment Type, and its CreateInstance factory method to instantiate an empty instance of your subclassed Appointment Type. On your custom data provider subclass you override the InitializeAppointmentBindings method to return an instance of your AppointmentBinding-subclass to be used by the AppointmentBinding property, so your data bindings and factory method are available when the infrastructure needs access to it.
The benefits of this wiring these classes up, is you can call AddCustomParameter in your custom data provider subclass to specify additional stored proc parameters you want passed to SQL Server (it goes without saying the stored procs need to have been modified with columns for your extra properties). Additionally, the infrastructure seamlessly handles mapping values/types in the result set onto a new instance of your Appointment subclass (created with that CreateInstance factory method) when everything is read in. It is the instructions annotated earlier using the WebScheduleDataBindingAttribute that drives this. I should note it only supports binding primitive value types, so it won't map BLOBs and XML sent back in a result set. If you have additional properties which are complex, then you will need to handle the InitializeActivity event which happens after data binding to make the follow-up calls to your database and override the AddActivity(AddActivityContext) and UpdateActivity(UpdateActivityContext) methods first by calling the base method, and then adding additional code for any additional data operations your new properties require that fall outside the purlieu of what the infrastructure handles.
The goal of the data provider, as relates to your request, is only to persist changes in these additional properties of yours. Don't be afraid to brush the data provider aside and put stuff into (and pull updates out of) the Activities collection on WebScheduleInfo directly.
For a general purpose custom data provider (not RDBMS-specific, consequently with none of the constraints nor helpful features of the afforementioned data provider infrastructure) you can attach a class implementing the IDataFetch and IDataUpdate interfaces to the DataFetch and DataUpdate properties (respectively) of WebScheduleInfo. Their methods give you the opportunitiy (and responsibility) to act whenever an Appointment needs to be loaded or saved.
I am not as familiar with customizing the Appointment dialog and Javascript on the client-side, but you definitely want to make sure you follow our guidelines for customizing the forms and then it'd be a good idea to go through this thread by Christopher Bishop, who seems to know the process pretty well. If push came to shove, what I would do (mind you, not being as familiar with the client-side goings-on) is harvest the additional property values by looping over the Activities collection in the Page's PreRender event, render them down to the page as hidden <input> fields, and when the user opened an Appointment dialog I'd use some Javascript in a <script> block on my custom Appointment form for plucking those hidden fields off my opener into the custom fields of my Appointment dialog.
HTH,
Looking at this solution to extend our Appointments all the way to the SQL Server data level.
I'm confused about the "-Member" suffix.
Has anyone found a good example or what Derek is talking about?