Back to Devexpress

ASPxScheduler.DateNavigatorQueryActiveViewType Event

aspnet-devexpress-dot-web-dot-aspxscheduler-dot-aspxscheduler-b899709d.md

latest4.2 KB
Original Source

ASPxScheduler.DateNavigatorQueryActiveViewType Event

Enables you to specify a view type to which the Scheduler switches after the end-user changes selected dates in the DateNavigator control.

Namespace : DevExpress.Web.ASPxScheduler

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

NuGet Package : DevExpress.Web.Scheduler

Declaration

csharp
public event DateNavigatorQueryActiveViewTypeHandler DateNavigatorQueryActiveViewType
vb
Public Event DateNavigatorQueryActiveViewType As DateNavigatorQueryActiveViewTypeHandler

Event Data

The DateNavigatorQueryActiveViewType event's data class is DateNavigatorQueryActiveViewTypeEventArgs. The following properties provide information specific to this event:

PropertyDescription
NewViewTypeGets or sets the type of the view to be used by the scheduler to show its data after the date range selected in the bound DateNavigator has been changed.
OldViewTypeGets the type of the view used by the scheduler to show its data before the date range selected in the bound DateNavigator is changed.
SelectedDaysGets the collection of dates selected in the DateNavigator bound to scheduler.

Remarks

The DateNavigatorQueryActiveViewType event fires when the end-user finishes selecting dates in the ASPxDateNavigator control.

You can analyze dates selected in the Date Navigator. These dates are available via the DateNavigatorQueryActiveViewTypeEventArgs.SelectedDays. Then, you can decide whether to change the view of the Scheduler or not. The former view type is available via the DateNavigatorQueryActiveViewTypeEventArgs.OldViewType property. The DateNavigatorQueryActiveViewTypeEventArgs.NewViewType property contains the view type proposed by the Date Navigator. You can leave it as it is or change as your needs dictate.

The following code prohibits changing the view by selecting dates in the Date Navigator, except when the only date selected is the current date.

csharp
private void ASPxScheduler1_DateNavigatorQueryActiveViewType(object sender, DateNavigatorQueryActiveViewTypeEventArgs e)
{
    if (e.SelectedDays.Contains(new TimeInterval(DateTime.Now, DateTime.Now.AddHours(1))))
        e.NewViewType = SchedulerViewType.Day;
    else
        e.NewViewType = e.OldViewType;
}
vb
Private Sub ASPxScheduler1_DateNavigatorQueryActiveViewType(ByVal sender As Object,_
 ByVal e As DateNavigatorQueryActiveViewTypeEventArgs)
    If e.SelectedDays.Contains(New TimeInterval(DateTime.Now, DateTime.Now.AddHours(1))) Then
        e.NewViewType = SchedulerViewType.Day
    Else
        e.NewViewType = e.OldViewType
    End If
End Sub

See Also

DateNavigatorQueryActiveViewTypeEventArgs

ASPxDateNavigator

ASPxScheduler Class

ASPxScheduler Members

DevExpress.Web.ASPxScheduler Namespace