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

BadgeBuilder

Methods

CutoutBorder(System.Boolean)

Specifies whether or not to render an additional "cutout" border around the Badge.

Parameters

value - System.Boolean

The value that enables the border.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .CutoutBorder(false)
            )

Icon(System.String)

Defines the name for an existing icon in a Kendo UI theme or SVG content. The icon is rendered inside the Badge by a 'span.k-icon' or 'span.k-svg-icon' element.

Parameters

value - System.String

The value that configures the icon.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Icon("user")
            )

Max(System.Double)

If text is a number, it will cap that number.

Parameters

value - System.Double

The value that configures the max.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text(100.2f)
                   .Max(99)
            )

Template(System.String)

The template that renders the content of the Badge.

Parameters

value - System.String

The value that configures the template.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("120")
                   .Template("#= +this._text > 100 ? 'a lot' : this._text #")
            )

TemplateId(System.String)

The template that renders the content of the Badge.

Parameters

value - System.String

The name of the external Kendo UI template.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("15")
                   .TemplateId("sentTemplate")
            )
            <script id="sentTemplate" type="text/x-kendo-template">
                #= this._text # items
            </script>

TemplateView(System.Web.Mvc.MvcHtmlString)

The template that renders the content of the Badge.

Parameters

value - System.Web.Mvc.MvcHtmlString

The Razor View that will be used for rendering the Badge content.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("100")
                   .TemplateView(Html.Partial("BadgeTemplateView"))
            )

TemplateHandler(System.String)

The template that renders the content of the Badge.

Parameters

value - System.String

The JavaScript function that will return the Badge content.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("100")
                   .TemplateHandler("getBadgeContent")
            )
            <script>
                function getBadgeContent() {
                    if(this._text > 100) {
                        return 'a lot';
                    } else return this._text;
                }
            </script>

Template(Kendo.Mvc.UI.TemplateBuilder)

The template that renders the content of the Badge.

Parameters

template - TemplateBuilder<TModel>

A Template component that configures the template.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Template(Html.Kendo().Template().AddHtml("<b>Most Popular</b>"))
            )

Text(System.String)

The text of the Badge. The valid input includes a string, number, or object with the 'toString()' method. The default value is an empty string.

Parameters

value - System.String

The value for the Text option.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("Most Popular")
            )

Visible(System.Boolean)

If set to 'false', the Badge will not be displayed.

Parameters

value - System.Boolean

The value that configures the visibility of the Badge.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("Most Popular")
                   .Visible(false)
            )

Size(Kendo.Mvc.UI.BadgeSize)

Defines the size of the Badge.

Parameters

value - BadgeSize

The value that configures the size.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("Most Popular")
                   .Size(BadgeSize.Large)
            )

Align(Kendo.Mvc.UI.BadgeAlign)

Defines the alignment of the Badge when it is integrated into a Button.

Parameters

value - BadgeAlign

The value that configures the Badge alignment.

Example


            @(Html.Kendo().Button()
              .Name("save")
              .Content("Save")
              .Badge(b => b
                .Align(BadgeAlign.TopStart)
                .Icon("save")
              )
            )

Position(Kendo.Mvc.UI.BadgePosition)

Defines the position of the Badge when it is integrated into a Button.

Parameters

value - BadgePosition

The value that configures the position.

Example


            @(Html.Kendo().Button()
              .Name("save")
              .Content("Save")
              .Badge(b => b
                .Position(BadgePosition.Edge)
                .Icon("save")
              )
            )

Rounded(Kendo.Mvc.UI.Rounded)

Defines the rounded appearance of the Badge.

Parameters

value - Rounded

The value that configures the rounding of the Badge.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("Most Popular")
                   .Rounded(Rounded.Large)
            )

ThemeColor(Kendo.Mvc.UI.BadgeColor)

Defines the color applied of the Badge.

Parameters

value - BadgeColor

The value that configures the theme color.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("user")
                   .ThemeColor(BadgeColor.Primary)
            )

FillMode(Kendo.Mvc.UI.BadgeFill)

Defines how theme colors are applied to a Badge.

Parameters

value - BadgeFill

The value that configures the fill mode.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("user")
                   .FillMode(BadgeFill.Outline)
            )

Text(System.Single)

The text of the Badge. The valid input includes a string, number, or object with the 'toString()' method. The default value is an empty string.

Parameters

value - System.Single

The value for the Text option.

Example


             @(Html.Kendo().Badge()
                   .Name("badge")
                   .Text("100")
            )

ToComponent()

Returns the internal view component.

Name(System.String)

Sets the name of the component.

Parameters

componentName - System.String

The name of the component.

Example


            @(Html.Kendo().Grid<OrderViewModel>()
               .Name("grid")
               .Columns(columns =>
               {
                   columns.Bound(p => p.OrderID).Filterable(false);
                   columns.Bound(p => p.Freight);  
               })
               .DataSource(dataSource => dataSource
                   .Ajax()
                   .PageSize(20)
                   .Read(read => read.Action("Orders_Read", "Grid"))
               )
            )

Deferred(System.Boolean)

Suppress initialization script rendering. Note that this options should be used in conjunction with

Parameters

deferred - System.Boolean

ModelMetadata(System.Web.Mvc.ModelMetadata)

Uses the Metadata of the Model.

Parameters

modelMetadata - System.Web.Mvc.ModelMetadata

The metadata set for the Model

HtmlAttributes(System.Object)

Sets the HTML attributes.

Parameters

attributes - System.Object

The HTML attributes.

HtmlAttributes(System.Collections.Generic.IDictionary)

Parameters

attributes - System.Collections.Generic.IDictionary<String,Object>

AsModule(System.Boolean)

Specifies whether the initialization script of the component will be rendered as a JavaScript module.

Parameters

value - System.Boolean

AsChildComponent()

Render()

Renders the component.

Example


            @(@Page Inherits="System.Web.Mvc.ViewPage<IEnumerable<Product>>" )
            @( Html.Kendo().Grid(Model)
                .Name("grid")
                .DetailTemplate(product => {
                    )
                       Product Details:
                       <div>Product Name: @( product.ProductName )</div>
                       <div>Units In Stock: @( product.UnitsInStock )</div>
                    @(
                })
                .Render();
            )

ScriptAttributes(System.Object,System.Boolean)

Sets the JavaScript attributes to the initialization script.

Parameters

attributes - System.Object

The JavaScript attributes.

overrideAttributes - System.Boolean

Argument which determines whether attributes should be overriden.

ScriptAttributes(System.Collections.Generic.IDictionary,System.Boolean)

Sets the JavaScript attributes to the initialization script.

Parameters

attributes - System.Collections.Generic.IDictionary<String,Object>

The JavaScript attributes.

overrideAttributes - System.Boolean

Argument which determines whether attributes should be overriden.

ToHtmlString()

ToClientTemplate()

In this article
Not finding the help you need?