Skip to main content
All docs
V24.1

DxScheduler.DateNavigatorTextTemplate Property

Specifies the template used to display text in the Scheduler’s Date Navigator.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public RenderFragment<SchedulerViewInfo> DateNavigatorTextTemplate { get; set; }

Property Value

Type Description
RenderFragment<SchedulerViewInfo>

The template content.

Remarks

The Scheduler’s Date Navigator displays a date or date range that corresponds to the current Scheduler view. These dates have a standard .NET format.

Scheduler - Custom Close Button

You can use the DateNavigatorTextTemplate to customize the text displayed in the Date Navigator. The following code hides the month/year part for the start date if both start and end dates have the same month/year.

@using MyProject.Services

<DxScheduler DataStorage="@DataStorage">
    <Views>
        <DxSchedulerWeekView ShowWorkTimeOnly="true" />
        <DxSchedulerWorkWeekView ShowWorkTimeOnly="true" />
        <DxSchedulerMonthView />
    </Views>
    <DateNavigatorTextTemplate><span>@CalculateDateString(context)</span></DateNavigatorTextTemplate>
</DxScheduler>

@code {
    DxSchedulerDataStorage DataStorage = new DxSchedulerDataStorage() {
            AppointmentsSource = AppointmentCollection.GetAppointments(),
            AppointmentMappings = new DxSchedulerAppointmentMappings() {
                Type = "AppointmentType",
                Start = "StartDate",
                End = "EndDate",
                Subject = "Caption",
                AllDay = "AllDay",
                LabelId = "Label",
                StatusId = "Status",
                RecurrenceInfo = "Recurrence"
            }
        };

    string CalculateDateString(SchedulerViewInfo viewInfo) {
        if (viewInfo.ActiveViewType == SchedulerViewType.Month) {
            return viewInfo.VisibleTimeRange.Start.ToString("MMM yyyy");
        }
        else {
            if (viewInfo.VisibleTimeRange.End - viewInfo.VisibleTimeRange.Start < TimeSpan.FromDays(1)) {
                return viewInfo.VisibleTimeRange.Start.ToString("dd MMM yyyy");
            }
            else {
                if (viewInfo.VisibleTimeRange.Start.Year != viewInfo.VisibleTimeRange.End.Year)
                    return viewInfo.VisibleTimeRange.Start.ToString("dd MMM yyyy") + " - " + viewInfo.VisibleTimeRange.End.ToString("dd MMM yyyy");
                else {
                    if (viewInfo.VisibleTimeRange.Start.Month != viewInfo.VisibleTimeRange.End.Month)
                        return viewInfo.VisibleTimeRange.Start.ToString("dd MMM") + " - " + viewInfo.VisibleTimeRange.End.ToString("dd MMM yyyy");
                    else
                        return viewInfo.VisibleTimeRange.Start.ToString("dd") + " - " + viewInfo.VisibleTimeRange.End.ToString("dd MMM yyyy");
                }
            }
        }
    }
}

Scheduler - Custom Close Button

See Also