Skip to main content
A newer version of this page is available. .

Data Binding

  • 4 minutes to read

The Scheduler can work with data that is bound to an external data source (data-bound mode) or use the internal storage (unbound mode). Although the common scenarios use external databases, and so require the control to be bound to data, the unbound mode also has its own advantages.

Unbound mode

If you do not bind a data source to the SchedulerDataStorage component, it will maintain appointments and resources in its internal storage system, so you can simply drop the Scheduler control on a form and instantly get a fully functioning calendar.

Unbound mode is a quick and easy way to get started with the Scheduler control and explore its features or when you need to manually control or manage data. Note the following tips when using the Scheduler in Unbound mode:

  • The data entered into the scheduler are contained in a SchedulerDataStorage instance. When this object is disposed of (e.g., when the application closes), all data are lost.
  • You can combine data-aware and unbound modes. For instance, you can store resources in an external data table but use unbound mode for appointments.
  • Mappings are unnecessary.

You can add and remove objects in respective collections manually, and use built-in methods to save and load in XML format. The following table lists SchedulerDataStorage collections and respective methods.

Object Notation to Access a Collection Method to Load Method to Save
Appointment SchedulerDataStorage.Appointments.Items AppointmentCollection.ReadXml AppointmentCollection.WriteXml
Resource SchedulerDataStorage.Resources.Items ResourceCollection.ReadXml ResourceCollection.WriteXml
Dependency (Gantt View only) SchedulerDataStorage.AppointmentDependencies.Items AppointmentDependencyCollection.ReadXml AppointmentDependencyCollection.WriteXml
Labels SchedulerDataStorage.Labels.Items - -
Statuses SchedulerDataStorage.Statuses.Items - -

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E155.

Data-Bound Mode

In most instances, you will need to store your data in an external data source, such as a data table or custom record collection. In such cases, you should bind the scheduler to the required data source using the SchedulerDataStorage component (it is created automatically when you place the SchedulerControl on a form). This component allows you to specify the data source and define mappings, so that the scheduler knows which fields to use in order to obtain the start time, end time, appointment subject, location, etc. You don’t necessarily have to define all the mappings exposed by the SchedulerDataStorage. If you don’t intend to use all of the functionality offered by appointments, you can specify just a couple of required fields (the mappings for the Appointment.Start and the Appointment.End properties are mandatory).

You can define any number of custom fields and map them to the appointment’s custom properties. The data obtained from custom fields can be used to change appointment information displayed in the view. Custom fields can be exposed to end-users using the custom appointment editing form.

To use the XtraScheduler in bound mode, specify data sources for appointments and resources via the PersistentObjectStorage<T>.DataSource property of the corresponding storage.

Note that after each data source assignment the scheduler starts layout calculation asynchronously in several threads.

The data source can be the DataSet or the System.ComponentModel.BindingList<T> class instance, or any object that provides the IBindingList interface. You can use the ArrayList object, but in this case the SchedulerControl will be in read-only mode.

The ObservableCollection<T> can also be used as a data source. When you consider the type of items in this collection, make sure that the properties (to which the Scheduler fields are mapped) are of simple data types.

Appointment Labels and Statuses are not data-bound. They are stored in collections accessible using the AppointmentStorage.Labels and AppointmentStorage.Statuses properties. An individual label or status can be retrieved by its index or identifier (UserInterfaceObject.Id property). Collections are populated with default items when the scheduler storage is initialized.

The following topics regarding data binding are available.

  • Data Sources

    This topic describes the structure of data sources for the Scheduler. Read it to learn about the requirements for the Microsoft SQL Server and Microsoft Access tables, how to create an Object data source for binding to the Scheduler, and review examples of code and scripts.

  • Mappings

    This topic describes the mapping concept, and explains how to create mappings that are required for binding the Scheduler to a data source.

  • How to: Create a Gantt Chart Application

    This topic describes, step-by-step, how to bind the XtraScheduler to an SQL Server database at design time with additional requirements for the Gantt view.

  • Mappings Wizards

    This topic describes the mapping wizard. This design-time feature facilitates data field mapping, but can also be the source of bugs if auto-mapping is not used with caution.

  • FetchAppointments Event - Handling Large Datasets

    This topic answers a common question: what to do if the application is fetching unnecessary data, increasing server workload, and degrading overall performance.