Skip to main content

CalendarSettings.DayCellPrepared Property

Enables you to customize the cell’s appearance.

Namespace: DevExpress.Web.Mvc

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

NuGet Package: DevExpress.Web.Mvc5

#Declaration

public EventHandler<CalendarDayCellPreparedEventArgs> DayCellPrepared { get; set; }

#Property Value

Type Description
EventHandler<CalendarDayCellPreparedEventArgs>

A EventHandler<TEventArgs><CalendarDayCellPreparedEventArgs,> delegate method allowing you to implement custom processing.

#Example

The code sample below demonstrates how you can use the CalendarSettings.DayCellInitialize and CalendarSettings.DayCellPrepared properties to conditionally change the manner of rendering calendar days within a single month. The image below shows the result.

Calendar_Events

@{
    CalendarDemoHelper calendarHelper = new CalendarDemoHelper(Server.MapPath("~/App_Data/CalendarNotes.xml"));
}

@Html.DevExpress().Calendar(settings => {
    settings.Name = "calendar";
    settings.CallbackRouteValues = new { Controller = "Editors", Action = "CalendarPartial" };
    settings.VisibleDate = new DateTime(2010, 10, 1);
    settings.ReadOnly = true;
    settings.Properties.EnableMonthNavigation = false;
    settings.Properties.EnableYearNavigation = false;

    settings.DayCellInitialize = (sender, e) => {
        if (calendarHelper.GetNoteNodes(e.Date).Count > 0) {
            e.IsWeekend = false;
            e.NavigateUrl = string.Format("javascript:ShowNotes('{0}')", calendarHelper.GetDateString(e.Date));
        } else {
            e.IsWeekend = true;
        }
    };

    settings.DayCellPrepared = (sender, e) => {
        if (calendarHelper.GetNoteNodes(e.Date).Count > 0) {
            e.TextControl.ForeColor = Color.Black;
            e.TextControl.Font.Bold = true;
        }
    };
}).GetHtml()
See Also