badge

Gets or sets the badge of a button within the ButtonGroup. This method supports several usage scenarios:

  • Get badge value: When called with only the button parameter, returns the current badge text
  • Set badge value: When called with a button and string/number value, updates the badge text
  • Create badge: If the button doesn't have a badge, creates a new one with the specified value
  • Remove badge: When called with false as the value parameter, completely removes the badge from the button
  • Handle zero: Properly handles zero (0) as a valid badge value

Parameters

button Selector|Number

The target button specified either as a jQuery selector/object or as an button index.

value String|Boolean

The target value to be set or false to be removed.

Returns

String|kendo.ui.Button the badge value if invoked without parameters, otherwise the ButtonGroup object.

Example

<ul id="buttongroup">
    <li>Option 1</li>
    <li>Option 2</li>
    <li>Option 3</li>
</ul>

<script>
    var buttonGroup = $("#buttongroup").kendoButtonGroup({
        select: function(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
            console.log("selected index:" + e.indices);
        },
        index: 0
    }).data("kendoButtonGroup");

    buttonGroup.badge(0,5);
</script>
In this article
badge
Not finding the help you need?
Contact Support