Back to Devexpress

DxSchedulerDataStorage Class

blazor-devexpress-dot-blazor-5934d1b2.md

latest13.1 KB
Original Source

DxSchedulerDataStorage Class

A storage that supplies data for the Scheduler control.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public class DxSchedulerDataStorage :
    ISchedulerStoragePrivateSettings

The following members return DxSchedulerDataStorage objects:

LibraryRelated API Members
BlazorDxScheduler.DataStorage
SchedulerAppointmentFormInfo.DataStorage
XAF: Cross-Platform .NET App UI & Web APIISchedulerStorageService.CreateSchedulerDataStorage(ITypeInfo)
SchedulerListEditor.CreateSchedulerDataSource()
SchedulerListEditor.DataStorage

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:

  1. In the Razor @code block, use the constructor without parameters to create a DxSchedulerDataStorage object.
  2. Declare a class (for instance, Appointment) that stores appointment options.
  3. Create a collection of status source objects (Appointment class instances) and define their options.
  4. Assign the newly created collection to the storage’s AppointmentsSource property to fill the storage with a collection of data objects.
  5. 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 TypeSourceMappings
LabelsAppointmentLabelsSourceAppointmentLabelMappings
Status itemsAppointmentStatusSourceAppointmentStatusMappings
ResourcesResourcesSourceResourceMappings

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:

razor
<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"
        }
    };
}
csharp
public class Appointment
{
    public Appointment() { }
    public int AppointmentType { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
    public string Caption { get; set; }
    public string Description { get; set; }
    public string Location { get; set; }
    public int Label { get; set; }
    public int Status { get; set; }
    public bool AllDay { get; set; }
    public string Recurrence { get; set; }
}
csharp
public static partial class AppointmentCollection {
    public static List<Appointment> GetAppointments() {
        DateTime date = DateTime.Today;
        var dataSource = new List<Appointment>() {
            new Appointment {
                Caption = "Install New Router in Dev Room",
                StartDate = date + (new TimeSpan(0, 10, 0, 0)),
                EndDate = date + (new TimeSpan(0, 12, 0, 0)),
                Label = 6, 
                Status = 1
            },
            new Appointment {
                Caption = "Upgrade Personal Computers",
                StartDate = date + (new TimeSpan(0, 13, 0, 0)),
                EndDate = date + (new TimeSpan(0, 14, 30, 0)),
                Label = 1, 
                Status = 1
            },
            new Appointment {
                Caption = "Website Redesign Plan",
                StartDate = date + (new TimeSpan(1, 9, 30, 0)),
                EndDate = date + (new TimeSpan(1, 11, 30, 0)),
                Label = 1, 
                Status = 1
            },
            new Appointment {
                Caption = "New Brochures",
                StartDate = date + (new TimeSpan(1, 13, 30, 0)),
                EndDate = date + (new TimeSpan(1, 15, 15, 0)),
                Label = 8, 
                Status = 1
            },
            new Appointment {
                Caption = "Book Flights to San Fran for Sales Trip",
                StartDate = date + (new TimeSpan(1, 12, 0, 0)),
                EndDate = date + (new TimeSpan(1, 13, 0, 0)),
                AllDay = true,
                Label = 8, 
                Status = 1
            },
            new Appointment {
                Caption = "Approve Personal Computer Upgrade Plan",
                StartDate = date + (new TimeSpan(2, 10, 0, 0)),
                EndDate = date + (new TimeSpan(2, 12, 0, 0)),
                Label = 8, 
                Status = 1
            },
            new Appointment {
                Caption = "Final Budget Review",
                StartDate = date + (new TimeSpan(2, 13, 0, 0)),
                EndDate = date + (new TimeSpan(2, 15, 0, 0)),
                Label = 1, 
                Status = 1
            },
            new Appointment {
                Caption = "Install New Database",
                StartDate = date + (new TimeSpan(3, 9, 45, 0)),
                EndDate = date + (new TimeSpan(3, 11, 15, 0)),
                Label = 6, 
                Status = 1
            },
            new Appointment {
                Caption = "Approve New Online Marketing Strategy",
                StartDate = date + (new TimeSpan(3, 12, 0, 0)),
                EndDate = date + (new TimeSpan(3, 14, 0, 0)),
                Label = 1, 
                Status = 1
            },
            new Appointment {
                Caption = "Customer Workshop",
                StartDate = date + (new TimeSpan(4, 11, 0, 0)),
                EndDate = date + (new TimeSpan(4, 12, 0, 0)),
                AllDay = true,
                Label = 8, 
                Status = 1
            },
            new Appointment {
                Caption = "Prepare 2015 Marketing Plan",
                StartDate = date + (new TimeSpan(4, 11, 0, 0)),
                EndDate = date + (new TimeSpan(4, 13, 30, 0)),
                Label = 1, 
                Status = 1
            },
            new Appointment {
                Caption = "Brochure Design Review",
                StartDate = date + (new TimeSpan(4, 14, 0, 0)),
                EndDate = date + (new TimeSpan(4, 15, 30, 0)),
                Label = 1, 
                Status = 1
            },
            new Appointment {
                Caption = "Create Icons for Website",
                StartDate = date + (new TimeSpan(5, 10, 0, 0)),
                EndDate = date + (new TimeSpan(5, 11, 30, 0)),
                Label = 1, 
                Status = 1
            },
            new Appointment {
                Caption = "Launch New Website",
                StartDate = date + (new TimeSpan(5, 12, 20, 0)),
                EndDate = date + (new TimeSpan(5, 14, 0, 0)),
                Label = 8, 
                Status = 1
            },
            new Appointment {
                Caption = "Upgrade Server Hardware",
                StartDate = date + (new TimeSpan(6, 11, 0, 0)),
                EndDate = date + (new TimeSpan(6, 13, 30, 0)),
                Label = 8, 
                Status = 1
            }
        };
        return dataSource;
    }
}

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.

MethodDescription
GetAppointmentItemByIdReturns an appointment with the specified identifier from the storage.
GetAppointmentsReturns appointments within the specified date-time range.
GetExceptionsReturns all exceptions to the specified pattern.
GetOccurrenceOrExceptionReturns an occurrence or exception with the specified recurrence index from the recurring series specified by its pattern.
GetOccurrencesAndExceptionsRetrieves the collection of occurrences and exceptions that belong to the specified time interval.
GetPatternReturns a pattern of the specified occurrence or exception.
GetLabelItemByIdReturns a label with the specified identifier from the storage.
GetResourceItemByIdReturns a resource item with the specified identifier from the Scheduler’s data storage.
GetStatusItemByIdReturns 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.

MethodDescription
CreateAppointmentItemCreates a new appointment item.
CreateLabelItemCreates a new label item.
CreateResourceItemCreates a new resource item.
CreateStatusItemCreates a new label item.

Inheritance

Object DxSchedulerDataStorage

See Also

DxSchedulerDataStorage Members

DevExpress.Blazor Namespace