DxSchedulerDataStorage Class
A storage that supplies data for the Scheduler control.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
public class DxSchedulerDataStorage :
ISchedulerStoragePrivateSettings
Remarks
The DxSchedulerDataStorage
object is an essential element required for the DxScheduler component operation. It contains source data for the following Scheduler persistent objects:
The DxSchedulerDataStorage
defines property mappings that map data fields to persistent object properties. This class also includes API used to retrieve persistent objects and to manage them.
The <DxScheduler>
component is bound to the DxSchedulerDataStorage
instance by the DxScheduler.DataStorage property.
Create Data Storage and Specify Mappings
Follow the steps below:
- In the Razor
@code
block, use the constructor without parameters to create aDxSchedulerDataStorage
object. - Declare a class (for instance,
Appointment
) that stores appointment options. - Create a collection of status source objects (
Appointment
class instances) and define their options. - Assign the newly created collection to the storage’s AppointmentsSource property to fill the storage with a collection of data objects.
- Assign a new DxSchedulerAppointmentMappings object to the DxSchedulerDataStorage.AppointmentMappings property. In this object, map the data source fields to appointment properties.
Optionally, you can use the following properties to specify other sources and mappings:
Object Type | Source | Mappings |
---|---|---|
Labels | AppointmentLabelsSource | AppointmentLabelMappings |
Status items | AppointmentStatusSource | AppointmentStatusMappings |
Resources | ResourcesSource | ResourceMappings |
Note
The DxSchedulerDataStorage
object contains built-in label and status collections. The Scheduler uses built-in collections when you do not specify label and status sources and mappings.
The following code snippet creates the DxSchedulerDataStorage
object, specify mappings, and assign this storage to the <DxScheduler>
component:
<DxScheduler StartDate="@DateTime.Today" DataStorage="@DataStorage">
<DxSchedulerWeekView ShowWorkTimeOnly="true"></DxSchedulerWeekView>
</DxScheduler>
@code {
DxSchedulerDataStorage DataStorage = new DxSchedulerDataStorage() {
AppointmentsSource = AppointmentCollection.GetAppointments(),
AppointmentMappings = new DxSchedulerAppointmentMappings() {
Type = "AppointmentType",
Start = "StartDate",
End = "EndDate",
Subject = "Caption",
AllDay = "AllDay",
Location = "Location",
Description = "Description",
LabelId = "Label",
StatusId = "Status",
RecurrenceInfo = "Recurrence"
}
};
}
Retrieve Persistent Objects
The DxSchedulerDataStorage
object includes methods to retrieve all kinds of persistent objects from the storage. The methods are listed in the table below.
Method | Description |
---|---|
GetAppointmentItemById | Returns an appointment with the specified identifier from the storage. |
GetAppointments | Returns appointments within the specified date-time range. |
GetExceptions | Returns all exceptions to the specified pattern. |
GetOccurrenceOrException | Returns an occurrence or exception with the specified recurrence index from the recurring series specified by its pattern. |
GetOccurrencesAndExceptions | Retrieves the collection of occurrences and exceptions that belong to the specified time interval. |
GetPattern | Returns a pattern of the specified occurrence or exception. |
GetLabelItemById | Returns a label with the specified identifier from the storage. |
GetResourceItemById | Returns a resource item with the specified identifier from the Scheduler’s data storage. |
GetStatusItemById | Returns a status with the specified identifier from the storage. |
Manage Persistent Objects
The DxSchedulerDataStorage
object includes methods that create a persistent object. In contrast with a simple object constructor, these methods create two objects - a persistent object along with a related source object - and establish mapping between them.
Method | Description |
---|---|
CreateAppointmentItem | Creates a new appointment item. |
CreateLabelItem | Creates a new label item. |
CreateResourceItem | Creates a new resource item. |
CreateStatusItem | Creates a new label item. |