Using a Data Provider
RadScheduler follows the Provider Design Pattern to allow for easy integration into existing applications. On the Microsoft Web site, the article Introduction To the Provider Model provides a detailed introduction to understanding this pattern.
You can use one of the providers supplied in the Telerik.Web.UI assembly, or you can implement your own.
To bind RadScheduler to a provider, set its Provider or ProviderName property. Use the ProviderName property when binding declaratively in the designer, and the Provider property when binding to a provider instance at runtime. Because providers supply information about appointments using the Telerik.Web.UI.Appointment type, you do not need to set the scheduler's DataKeyField, DataSubjectField, DataStartField, DataEndField, DataReminderField and DataRecurrenceParentKeyField properties. Similarly, you do not need to set the ResourceTypes property, as the provider supplies this information. Any values you set on the scheduler at design time are ignored.
This example shows how to declaratively bind RadScheduler to one of the supplied providers, using the ProviderName property.
Using the Solution Explorer, double click on the Web.config file. Locate the
tag at the very top. RadScheduler is designed to be used with providers configured in a custom section of the web.config file. The custom section requires a handler that is included in the Telerik.Web.UI assembly. Add a for this handler to the of your Web.config file:
<configSections> <sectionGroup name="telerik.web.ui"> <section name="radScheduler" type="Telerik.Web.UI.RadSchedulerConfigurationSection, Telerik.Web.UI, PublicKeyToken=121fae78165ba3d4" allowDefinition="MachineToApplication" /> </sectionGroup> </configSections>
The PublicKeyToken varies in different versions on RadControls. You can use JustDecompile, to see the PublicKeyToken for your version.Additionally, if the assembly is added to your GAC, you can see its Public Key Token there as well.
Now that you have declared a handler, add the
section to your Web.config file (if it is not already there), and in the section, declare the provider:
<telerik.web.ui> <radScheduler defaultAppointmentProvider="Integrated"> <appointmentProviders> <add name="XmlSchedulerProvider1" type="Telerik.Web.UI.XmlSchedulerProvider" fileName="~/App_Data/Appointments.xml" persistChanges="true"/> </appointmentProviders> </radScheduler> </telerik.web.ui>
Now that the provider will be loaded into your application, select your RadScheduler in the designer and set its ProviderName property to "XmlSchedulerProvider1".
Locate the Appointments.xml file, which can be found in "Live Demos\App_Data" folder, and copy it to the App_Data folder of your project.
You have now bound your scheduler using the ProviderName property. Run the application and note the custom resources supplied by the provider. The provider's persistChanges property accepts a boolean value and determines whether the newly added appointments will be persisted. Note, too, that unlike when binding using the DataSource or DataSourceID properties, you did not need to set the DataKeyField, DataSubjectField, DataStartField, DataEndField, DataRecurrenceField DataReminderField, and DataRecurrenceParentKeyField properties.