Back to Devexpress

FetchAppointmentsMethod Delegate

aspnetmvc-devexpress-dot-web-dot-mvc-78ca6853.md

latest4.2 KB
Original Source

FetchAppointmentsMethod Delegate

A delegate method that enables you to dynamically limit the number of appointments loaded into the Scheduler storage.

Namespace : DevExpress.Web.Mvc

Assembly : DevExpress.Web.Mvc5.v25.2.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public delegate object FetchAppointmentsMethod(
    FetchAppointmentsEventArgs args
);
vb
Public Delegate Function FetchAppointmentsMethod(
    args As FetchAppointmentsEventArgs
) As Object

Parameters

NameTypeDescription
argsFetchAppointmentsEventArgs

An FetchAppointmentsEventArgs object that contains the data specific for the ASPxSchedulerDataWebControlBase.FetchAppointments event.

|

Returns

Type
Object

Remarks

Specify the method that returns an IEnumerable appointment data source as an argument when calling the SchedulerExtension.Bind method override.

View Example: Scheduler - How to implement the FetchAppointment event functionality

cshtml
@Html.DevExpress().Scheduler(SchedulerSettingsHelper.CommonSchedulerSettings)
   .Bind(Model.FetchAppointments, Model.Resources).GetHtml()
csharp
public class SchedulerDataObject {
    public IEnumerable Appointments { get; set; }
    public IEnumerable Resources { get; set; }
    public DevExpress.Web.Mvc.FetchAppointmentsMethod FetchAppointments { get; set; }
}
public class SchedulerDataHelper {
    public static object FetchAppointmentsHelperMethod(FetchAppointmentsEventArgs args) {
        args.ForceReloadAppointments = true;
        SchedulingDataClassesDataContext db = new SchedulingDataClassesDataContext();
        return db.DBAppointments.Where(e => e.StartDate > args.Interval.Start && e.EndDate < args.Interval.End);
    }
}
vb
Public Class SchedulerDataObject
    Public Property Appointments() As IEnumerable
    Public Property Resources() As IEnumerable
    Public Property FetchAppointments() As DevExpress.Web.Mvc.FetchAppointmentsMethod
End Class
Public Class SchedulerDataHelper
  Public Shared Function FetchAppointmentsHelperMethod(ByVal args As FetchAppointmentsEventArgs) As Object
      args.ForceReloadAppointments = True
      Dim db As New SchedulingDataClassesDataContext()
  Return db.DBAppointments.Where(Function(e) (Convert.ToDateTime(e.StartDate) > args.Interval.Start AndAlso Convert.ToDateTime(e.EndDate) < args.Interval.End))
  End Function
End Class

There is nothing wrong in calling the FetchAppointment delegate multiple times. This happens because of PostData loading and interval changes. Generally, it is dependent on various factors, such as the current view type, the visibility of the Navigation buttons and the presence of the DateNavigator control bound to the Scheduler.

The FetchAppointment technique was primarily introduced in XtraScheduler and ASPxScheduler controls. The Scheduler MVC extension implements the FetchAppointment delegate because its ASP counterpart, the ASPxScheduler, provides the FetchAppointments event.

For more information, review the ASPxSchedulerDataWebControlBase.FetchAppointments method reference.

See Also

DevExpress.Web.Mvc Namespace