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

TemplateBuilder class.

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Type Parameters:

TModel

Syntax:

C#
public class TemplateBuilder<TModel> : HelperResult, IHtmlContent

Inheritance: objectHelperResultTemplateBuilder<TModel>

Implements: IHtmlContent

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

Constructors

Initializes a new instance of the TemplateBuilder<TModel> class.

C#
public TemplateBuilder(Template<TModel> template)
Parameters:templateTemplate<TModel>

Methods

Defines a Telerik UI component into the template.

C#
public TemplateBuilder<TModel> AddComponent(Action<WidgetFactory<TModel>> widgetBuilder)
Parameters:widgetBuilderAction<WidgetFactory<TModel>>

The action that defines the Telerik UI component.

Returns:

TemplateBuilder<TModel>

Returns the current TemplateBuilder<TModel> instance.

Example:
C#
@(Html.Kendo().Template()
.AddComponent(c =&gt; c.Button().Name("testBtn").Content("Settings"))
)

Allows setting combining conventional HTML elements with HtmlHelpers coming from the web framework.

C#
public TemplateBuilder<TModel> AddHtml(Func<object, object> html)
Parameters:htmlFunc<object, object>

The value that configures the HTML content.

Returns:

TemplateBuilder<TModel>

Returns the current TemplateBuilder<TModel> instance.

Example:
C#
@(Html.Kendo().Template()
.AddHtml(@&lt;text&gt;&lt;p&gt;HTML content&lt;/p&gt;&lt;/text&gt;)
)

Allows setting conventional HTML elements.

C#
public TemplateBuilder<TModel> AddHtml(string html)
Parameters:htmlstring

The value that configures the HTML content.

Returns:

TemplateBuilder<TModel>

Returns the current TemplateBuilder<TModel> instance.

Example:
C#
@(Html.Kendo().Template()
.AddHtml("&lt;p&gt;HTML content&lt;/p&gt;")
)

Serializes the template to a string that can be used in a form editor.

C#
public string ToFormEditor()
Returns:

string

A string representing the template serialized for form editing.

C#
public override string ToString()
Returns:

string

Overrides: object.ToString()

C#
public override void WriteTo(TextWriter writer, HtmlEncoder encoder)
Parameters:writerTextWriterencoderHtmlEncoder

Overrides: HelperResult.WriteTo(TextWriter, HtmlEncoder)