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

Defines the fluent interface for configuring the MonthTemplate.

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Syntax:

C#
public class MonthTemplateBuilder

Inheritance: objectMonthTemplateBuilder

Inherited Members object.GetType()object.MemberwiseClone()object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()...

Constructors

C#
public MonthTemplateBuilder(MonthTemplate monthTemplate)
Parameters:monthTemplateMonthTemplate

Properties

C#
protected MonthTemplate MonthTemplate { get; }

Methods

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

C#
public MonthTemplateBuilder Content(string content)
Parameters:contentstring

The content of the cell.

Returns:

MonthTemplateBuilder

Example:
C#
@(Html.Kendo().Calendar()
.Name("calendar")
.MonthTemplate(x => x.Content("<div class='my-custom-cell'>#= data.value#</div>"))
)

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

C#
public MonthTemplateBuilder Content<TModel>(TemplateBuilder<TModel> template)
Parameters:templateTemplateBuilder<TModel>

The content of the cell

Returns:

MonthTemplateBuilder

Example:
C#
@(Html.Kendo().Calendar()
.Name("calendar")
.MonthTemplate(monthTemplate =&gt; monthTemplate
.Content(Html.Kendo().Template()
.AddHtml("&lt;div class='my-custom-cell'&gt;${data.weekNumber}&lt;/div&gt;")
)
)
)

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

C#
public MonthTemplateBuilder ContentHandler(string content)
Parameters:contentstring

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

Returns:

MonthTemplateBuilder

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.MonthTemplate(x =&gt; x.ContentHandler("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 MonthTemplateBuilder ContentId(string id)
Parameters:idstring

The id of the external Kendo UI template.

Returns:

MonthTemplateBuilder

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.MonthTemplate(x =&gt; x.ContentId("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 content template partial view.

C#
public MonthTemplateBuilder ContentView(IHtmlString value)
Parameters:valueIHtmlString

The partial view that will be rendered for the content template.

Returns:

MonthTemplateBuilder

Example:
C#
@(Html.Kendo().Calendar()
.Name("calendar")
.Month(month =&gt;
{
month.ContentView(Html.Partial("_CustomCommand"));
})
)

Sets the template that renders the cells in the 'month' view, which are not in the min/max range.

C#
public MonthTemplateBuilder Empty(string empty)
Parameters:emptystring

The content of the empty cells.

Returns:

MonthTemplateBuilder

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.MonthTemplate(x =&gt; x.Empty("-"))
)

Sets the template that renders the cells in the 'month' view, which are not in the min/max range.

C#
public MonthTemplateBuilder Empty<TModel>(TemplateBuilder<TModel> template)
Parameters:templateTemplateBuilder<TModel>

The content of the empty cells.

Returns:

MonthTemplateBuilder

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

Sets the template that renders the cells in the "month" view, which are not in the min/max range.

C#
public MonthTemplateBuilder EmptyHandler(string empty)
Parameters:emptystring

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

Returns:

MonthTemplateBuilder

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.MonthTemplate(x =&gt; x.EmptyHandler("emptyTemplate"))
)
&lt;script&gt;
function emptyTemplate(data) {
return '-';
}
&lt;/script&gt;

Sets the template that renders the cells in the 'month' view, which are not in the min/max range.

C#
public MonthTemplateBuilder EmptyId(string id)
Parameters:idstring

The id of the external Kendo UI template.

Returns:

MonthTemplateBuilder

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.Min("01/01/2024")
.Max("10/01/2024")
.MonthTemplate(x =&gt; x.EmptyId("cell-template"))
)

Sets the empty template partial view.

C#
public MonthTemplateBuilder EmptyView(IHtmlString value)
Parameters:valueIHtmlString

The partial view that will be rendered for the empty template.

Returns:

MonthTemplateBuilder

Example:
C#
@(Html.Kendo().Calendar()
.Name("calendar")
.Month(month =&gt;
{
month.EmptyView(Html.Partial("_CustomCommand"));
})
)

Sets the template that renders the cells in "week number" column.

C#
public MonthTemplateBuilder WeekNumber(string weekNumber)
Parameters:weekNumberstring

The content of the week number cells.

Returns:

MonthTemplateBuilder

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.MonthTemplate(x =&gt; x.WeekNumber("&lt;div class='my-custom-cell'&gt;#= data.weekNumber#&lt;/div&gt;"))
)

Sets the template that renders the cells in "week number" column.

C#
public MonthTemplateBuilder WeekNumber<TModel>(TemplateBuilder<TModel> template)
Parameters:templateTemplateBuilder<TModel>

The content of the week number cells.

Returns:

MonthTemplateBuilder

Example:
C#
@(Html.Kendo().Calendar()
.Name("calendar")
.MonthTemplate(monthTemplate =&gt; monthTemplate
.WeekNumber(Html.Kendo().Template()
.AddHtml("&lt;div class='my-custom-cell'&gt;${data.weekNumber}&lt;/div&gt;")
)
)
)

Sets the template that renders the cells in "week" column.

C#
public MonthTemplateBuilder WeekNumberHandler(string weekNumber)
Parameters:weekNumberstring

The JavaScript function that will return the content of the cells in the "week" column.

Returns:

MonthTemplateBuilder

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.MonthTemplate(x =&gt; x.WeekNumberHandler("weekNumberTemplate"))
)
&lt;script&gt;
function weekNumberTemplate(data) {
return `&lt;span&gt;${data.weekNumber }&lt;/span&gt;`;
}
&lt;/script&gt;

Sets the template that renders the cells in "week number" column.

C#
public MonthTemplateBuilder WeekNumberId(string id)
Parameters:idstring

The id of the external Kendo UI template.

Returns:

MonthTemplateBuilder

Example:
C#
@( Html.Kendo().Calendar()
.Name("calendar")
.MonthTemplate(x =&gt; x.WeekNumberId("week-number-template"))
)
&lt;script id="week-number-template" type="text/x-kendo-template"&gt;
&lt;span class='custom-week-num'&gt;#=data.weekNumber #&lt;/span&gt;
&lt;/script&gt;

Sets the weeknumber template partial view.

C#
public MonthTemplateBuilder WeekNumberView(IHtmlString value)
Parameters:valueIHtmlString

The partial view that will be rendered for the week number template.

Returns:

MonthTemplateBuilder

Example:
C#
@(Html.Kendo().Calendar()
.Name("calendar")
.Month(month =&gt;
{
month.WeekNumberView(Html.Partial("_CustomCommand"));
})
)