How to configure the VisibleRange
The built-in RadScheduler ViewDefinitions have specific ways to determine what the visible range will be when the CurrentDate property is set:
Type | VisibleRangeStart | VisibleDays |
---|---|---|
DayViewDefinition | CurrentDate | 1 |
WeekViewDefinition | The first day of the week, containing CurrentDate | 7 |
MonthViewDefinition | The first day of the first week of the month, containing CurrentDate | 42 |
TimelineViewDefinition | CurrentDate | 7 |
The VisibleRangeEnd is VisibleRangeStart+VisibleDays for all view definitions.
The easiest way to create a WeekViewDefinition that behaves like the DayViewDefinition is to use a DayViewDefinition and set its VisibleDays=7.
For advanced customization of the VisibleRange the ViewDefinitionBase class provides two virtual methods:
Example 1: ViewDefinitionBase virtual methods
protected virtual DateTime GetVisibleRangeStart (DateTime currentDate, CultureInfo culture, DayOfWeek? firstDayOfWeek);
protected virtual DateTime GetVisibleRangeEnd(DateTime currentDate, CultureInfo culture, DayOfWeek? firstDayOfWeek);
Example 2: Implementing a custom view definiton
public class CustomMonthViewDefinition : MonthViewDefinition
{
protected override DateTime GetVisibleRangeStart(DateTime currentDate, CultureInfo culture, DayOfWeek? firstDayOfWeek)
{
return CalendarHelper.GetFirstDayOfWeek(currentDate, firstDayOfWeek.Value);
}
}
Here is how to use the CustomMonthViewDefinition:
Example 3: Adding the CustomMonthViewDefinition to the ViewDefinitions
<telerik:RadScheduler>
<telerik:RadScheduler.ViewDefinitions>
<local:CustomMonthViewDefinition />
</telerik:RadScheduler.ViewDefinitions>
</telerik:RadScheduler>