New to Telerik UI for ASP.NET Core? Start a free 30-day trial

Defines the fluent API for configuring the Telerik UI for ASP.NET Core Calendar

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Syntax:

C#
public class CalendarBuilder : WidgetBuilderBase<Calendar, CalendarBuilder>, IHtmlContent

Inheritance: objectHelperResultWidgetBuilderBase<Calendar, CalendarBuilder>CalendarBuilder

Implements: IHtmlContent

Inherited Members WidgetBuilderBase<Calendar, CalendarBuilder>.ToComponent()WidgetBuilderBase<Calendar, CalendarBuilder>.Expression(string)WidgetBuilderBase<Calendar, CalendarBuilder>.Explorer(ModelExplorer)WidgetBuilderBase<Calendar, CalendarBuilder>.Name(string)WidgetBuilderBase<Calendar, CalendarBuilder>.Deferred(bool)WidgetBuilderBase<Calendar, CalendarBuilder>.HtmlAttributes(object)WidgetBuilderBase<Calendar, CalendarBuilder>.HtmlAttributes(IDictionary<string, object>)WidgetBuilderBase<Calendar, CalendarBuilder>.ScriptAttributes(object, bool)WidgetBuilderBase<Calendar, CalendarBuilder>.ScriptAttributes(IDictionary<string, object>, bool)WidgetBuilderBase<Calendar, CalendarBuilder>.Render()WidgetBuilderBase<Calendar, CalendarBuilder>.ToHtmlString()WidgetBuilderBase<Calendar, CalendarBuilder>.WriteTo(TextWriter, HtmlEncoder)WidgetBuilderBase<Calendar, CalendarBuilder>.ToClientTemplate()WidgetBuilderBase<Calendar, CalendarBuilder>.AsModule(bool)WidgetBuilderBase<Calendar, CalendarBuilder>.ComponentWidgetBuilderBase<Calendar, CalendarBuilder>.ContainerHelperResult.WriteTo(TextWriter, HtmlEncoder)HelperResult.WriteActionobject.GetType()object.MemberwiseClone()object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()...

Constructors

Initializes a new instance of the CalendarBuilder class.

C#
public CalendarBuilder(Calendar component)
Parameters:componentCalendar

Methods

Enables the user to select an end date that is before the start date. This option is available only when the selectable configuration is set to range.

C#
public CalendarBuilder AllowReverse()
Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Enables the user to select an end date that is before the start date. This option is available only when the selectable configuration is set to range.

C#
public CalendarBuilder AllowReverse(bool value)
Parameters:valuebool

The value for AllowReverse

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@(Html.Kendo().Calendar()
.Name("calendar")
.Selectable("range")
.AllowReverse()
)

Defines the century cell format.

C#
public CalendarBuilder CenturyCellsFormat(CenturyCellsFormats value)
Parameters:valueCenturyCellsFormats

The value for CenturyCellsFormat

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@(Html.Kendo().Calendar()
.Name("calendar")
.Start(CalendarView.Century)
.CenturyCellsFormat(CenturyCellsFormats.Short)
)

Specifies the component type of the widget. "classic" - Uses the standard rendering of the widget. or "modern" - Uses new rendering with a fresh and modern look and feel..

C#
public CalendarBuilder ComponentType(string value)
Parameters:valuestring

The value for ComponentType

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.ComponentType("modern")
)

Specifies the culture info used by the component. A valid kendo culture file must be added to the page in order for the example to work. <script src="https://cdn.jsdelivr.net/npm/@progress/kendo-ui@{version}/umd/cultures/kendo.culture.de-DE.min.js"&gt;&lt;/script>

C#
public CalendarBuilder Culture(string value)
Parameters:valuestring

The value for Culture

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.Culture("de-DE")
)

Specifies a list of dates, which will be passed to the month template.

C#
public CalendarBuilder Dates(params DateTime[] value)
Parameters:valueDateTime[]

The value for Dates

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Specifies the navigation depth.

C#
public CalendarBuilder Depth(CalendarView value)
Parameters:valueCalendarView

The value for Depth

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Start(CalendarView.Month)
.Depth(CalendarView.Year)
)

Specifies the disabled dates in the Calendar component as an array of DayOfWeek enums.

C#
public CalendarBuilder DisableDates(params DayOfWeek[] days)
Parameters:daysDayOfWeek[]

The array of DayOfWeek enums.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.DisableDates(DayofWeek.Saturday, DayOfWeek.Sunday)
)

Specifies the disabled dates in the Calendar by using a JavaScript function.

C#
public CalendarBuilder DisableDates(string handler)
Parameters:handlerstring

The JavaScript function that will set the disabled dates.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.DisableDates("disableDates")
)
&lt;script&gt;
function disableDates(date) {
var disabled = [13, 14, 20, 21];
if (date &amp;amp; disabled.indexOf(date.getDate()) &gt; -1 ) {
return true;
} else return false;
}
&lt;/script&gt;

Configures the client-side events.

C#
public CalendarBuilder Events(Action<CalendarEventBuilder> configurator)
Parameters:configuratorAction<CalendarEventBuilder>

The client events action.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@(Html.Kendo().Calendar()
.Name("Calendar")
.Events(events =&gt; events
.Change("onChange")
)
)

Enables the Calendar footer. If set to 'false', the footer will not be displayed.

C#
public CalendarBuilder Footer(bool footer)
Parameters:footerbool

The value that configures the visibility of the footer.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Footer(false)
)

The template which renders the footer. If false, the footer will not be rendered.

C#
public CalendarBuilder Footer(string value)
Parameters:valuestring

The value for Footer

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Footer(false)
)

Sets the template that renders the Calendar footer.

C#
public CalendarBuilder FooterId(string id)
Parameters:idstring

The id of the external Kendo UI template.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.FooterId("footer-template")
)
&lt;script id="footer-template" type="text/x-kendo-template"&gt;
Today - #: kendo.toString(data, "d") #
&lt;/script&gt;

Specifies the format, which is used to parse value set with value() method.

C#
public CalendarBuilder Format(string value)
Parameters:valuestring

The value for Format

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Format("dd/MM/yyyy")
.Value(07/06/2024)
)

Specifies the maximum date, which the calendar can show.

C#
public CalendarBuilder Max(DateTime value)
Parameters:valueDateTime

The value for Max

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Max(new DateTime(2024,12,31))
)

Sets the maximum date that can be selected in the Calendar.

C#
public CalendarBuilder Max(string date)
Parameters:datestring

The value that configures maximum date.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Max("12/01/2024")
)

Allows localization of the strings that are used in the widget.

C#
public CalendarBuilder Messages(Action<CalendarMessagesSettingsBuilder> configurator)
Parameters:configuratorAction<CalendarMessagesSettingsBuilder>

The CalendarMessagesSettingsBuilder for the messages setting.

Returns:

CalendarBuilder

Returns the current instance of CalendarBuilder .

Specifies the minimum date, which the calendar can show.

C#
public CalendarBuilder Min(DateTime value)
Parameters:valueDateTime

The value for Min

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Min(new DateTime(2024,1,1))
)

Sets the minimum date that can be selected in the Calendar.

C#
public CalendarBuilder Min(string date)
Parameters:datestring

The value that configures minimum date.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Min("01/01/2024")
)

Sets the template that renders the cells in the "month" view.

C#
public CalendarBuilder MonthTemplate(Action<MonthTemplateBuilder> monthTemplateAction)
Parameters:monthTemplateActionAction<MonthTemplateBuilder>

The action that configures the template settings of the "month" view.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.MonthTemplate(month =&gt; month.Content("#= data.value #"))
)

Sets the template that renders the cells in the 'month' view.

C#
public CalendarBuilder MonthTemplate(string content)
Parameters:contentstring

The value that configures the template.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.MonthTemplate("#= data.value #")
)

Sets the template that renders the cells in the "month" view.

C#
public CalendarBuilder MonthTemplate<TModel>(TemplateBuilder<TModel> template)
Parameters:templateTemplateBuilder<TModel>

The value that configures the template.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.MonthTemplate(Html.Kendo().Template()
.AddHtml("test")
)
)

Sets the template that renders the cells in the 'month' view.

C#
public CalendarBuilder MonthTemplateHandler(string templateHandler)
Parameters:templateHandlerstring

The JavaScript function that will return the content of the cells in the 'month' view.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.MonthTemplateHandler("monthTemplate")
)
&lt;script&gt;
function monthTemplate(data) {
if(data.value &lt; 10) {
return 'exhibition';
}
return 'party';
}
&lt;/script&gt;

Sets the template that renders the cells in the 'month' view.

C#
public CalendarBuilder MonthTemplateId(string id)
Parameters:idstring

The id of the external Kendo UI template.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.MonthTemplateId("cell-template")
)
&lt;script id="cell-template" type="text/x-kendo-template"&gt;
&lt;div class="#= data.value &lt; 10 ? 'exhibition' : 'party' #"&gt;
#= data.value #
&lt;/div&gt;
&lt;/script&gt;

Sets the template that renders the cells in the 'month' view.

C#
public CalendarBuilder MonthTemplateView(IHtmlContent templateView)
Parameters:templateViewIHtmlContent

The Razor View that will be used for rendering the cells content in the 'month' view.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.MonthTemplateView(Html.Partial("MonthTemplateView"))
)

Specifies an initial range selection. This option is available only when the selectable configuration is set to range.

C#
public CalendarBuilder Range(Action<CalendarRangeSettingsBuilder> configurator)
Parameters:configuratorAction<CalendarRangeSettingsBuilder>

The CalendarRangeSettingsBuilder for the range setting.

Returns:

CalendarBuilder

Returns the current instance of CalendarBuilder .

By default user is able to select a single date. The property can also be set to multiple or range. More information about the different selection modes can be found in the Selection article.

C#
public CalendarBuilder Selectable(string value)
Parameters:valuestring

The value for Selectable

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Selectable("multiple")
)

Specifies which dates to be selected when the calendar is initialized.

C#
public CalendarBuilder SelectDates(params DateTime[] value)
Parameters:valueDateTime[]

The value for SelectDates

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Selectable("multiple")
.SelectDates(new DateTime[] { new DateTime(2024,7,5), new DateTime(2024,7,10) })
)

Configures the selection settings of the Calendar.

C#
public CalendarBuilder Selection(Action<CalendarSelectionSettingsBuilder> selectionAction)
Parameters:selectionActionAction<CalendarSelectionSettingsBuilder>

The action that configures the selection settings.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Selection(s =&gt; s.Action("Save", "Home", new { id = "123" }).Dates(new List&lt;DateTime&gt;(){new DateTime(2024,1,4), new DateTime(2024,1,5)}))
)

When this configuration is enabled, the calendar will render days from the previous and next months in the current view.

C#
public CalendarBuilder ShowOtherMonthDays(bool value)
Parameters:valuebool

The value for ShowOtherMonthDays

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@(Html.Kendo().Calendar()
.Name("calendar")
.ShowOtherMonthDays(false)
)

Specifies the start view. The following settings are available for the start value: "month" - Shows the days of the month.; "year" - Shows the months of the year.; "decade" - Shows the years of the decade. or "century" - Shows the decades from the century..

C#
public CalendarBuilder Start(CalendarView value)
Parameters:valueCalendarView

The value for Start

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Start(CalendarView.Month)
)

Sets the selected date in the Calendar.

C#
public CalendarBuilder Value(DateTime? date)
Parameters:dateDateTime?

The DateTime value that sets the selected date.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Value(new DateTime(2024,07,05))
)

Specifies the selected date.

C#
public CalendarBuilder Value(DateTime value)
Parameters:valueDateTime

The value for Value

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Value("2024/07/05")
)

Sets the selected date in the Calendar.

C#
public CalendarBuilder Value(string date)
Parameters:datestring

The value that sets the selected date.

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.Value("2024/07/05")
)

If set to true a week of the year will be shown on the left side of the calendar.

C#
public CalendarBuilder WeekNumber()
Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

If set to true a week of the year will be shown on the left side of the calendar.

C#
public CalendarBuilder WeekNumber(bool value)
Parameters:valuebool

The value for WeekNumber

Returns:

CalendarBuilder

Returns the current CalendarBuilder instance.

Example:
C#
@( Html.Kendo().Calendar()
.Name("Calendar")
.WeekNumber(true)
)