- 4 minutes to read
You are viewing documentation for the legacy WPF Scheduler control. If you’re starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.
This document introduces the Resource concept and describes how appointments can be assigned to different resources. It contains some real-life resource examples and demonstrates how appointments and resources can be linked.
What Is a Resource?
In real-life scheduling applications, an appointment is seldom processed “as is” and is usually assigned to different resources. There are different kinds of resources and the decision as to what should be a resource in a particular scheduling application depends upon the specifics of the task solved by the application. Here are some examples of scheduling tasks, illustrating what can be an appointment and a resource in these examples.
Resource: Every employee in this company.
Appointment: Any time interval spent by an employee to perform a particular task.
A Car Rental Agency.
Resource: Every car that is owned by this firm and can be leased.
Appointment: Any time interval during which any of the firm’s cars are leased.
An Educational Center.
Resources: Every teacher who works at this center or every room in this center.
Appointment: Any time interval when any one of the teachers is delivering a lecture in any of the rooms at the center.
Assigning Appointments to Resources
A single resource is an object which exposes the Resource interface. All of a scheduler’s resources are stored in ResourceStorage (which is a part of the Scheduler Storage and is accessed via its SchedulerStorage.ResourceStorage property). The collection of all resources is accessed via the ResourceStorage.Items property.
If a Resource Storage contains at least one resource, then it is possible to assign appointments to resources. This may be done in different ways, depending on whether resource sharing is enabled. Resource sharing means that an appointment can be associated with several resources.
Resources are not shared, i.e. the AppointmentStorage.ResourceSharing property is set to false.
To assign an appointment to a particular resource, the appointment’s Appointment.ResourceId property should be set to the ID of the appropriate resource. Note that the resource’s ID is accessed via its IPersistentObject.Id property.
The image below demonstrates this concept.
Resources are shared, i.e. the AppointmentStorage.ResourceSharing property is set to true.
The image below demonstrates this concept.
Grouping by Resources
A resource becomes visible in Scheduler Control when its data is shown, grouped by either dates (SchedulerControl.GroupType is set to SchedulerGroupType.Date) or by resources (SchedulerControl.GroupType is set to SchedulerGroupType.Resource).
If the Resource.Visible property of any resource is set to false and appointments grouping is enabled, then all appointments that belong to this resource will be hidden.
The following image demonstrates the common look of the Day View when appointments are grouped by resources.
In the grouped Timeline View, resources are shown vertically on the left.
If grouping is enabled, Resource Navigator is shown automatically. It can be used by end-users to scroll through resources and to change the number of resources shown at one time on screen.
For step-by-step instructions on how to provide resources for appointments, see the Provide Resources for Appointments document.
You can let end-users specify resources for display only in appointments associated with those resources. Apart from the mentioned Resource Navigator control, there are stand-alone controls that accomplish a similar task. The ResourcesCheckedListBoxControl, ResourcesComboBoxControl or the ResourcesPopupCheckedListBoxControl controls serve this purpose.
To filter resources programmatically, handle the SchedulerStorage.FilterResource event.
If the resource for an appointment is not specified, it is assumed that the appointment belongs to any resource. Use the OptionsView.ShowOnlyResourceAppointments property to specify its visibility. If the resource assigned to an appointment is not presented in a resource storage, this appointment is not loaded in appointment storage. It means that a Scheduler without resources does not display appointments with resources.