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

Changing Switch Messages Inside a Grid


Product Version 2019.3.1023
Product Progress® Telerik® UI for ASP.NET MVC


Is there a way to change the Switch message OK button and Cancel button while it is bound to a Telerik UI for ASP.NET MVC Grid row?


The Kendo UI Switch can be set as a ClientTemplate inside a Kendo UI Grid. The switch's messages can be configured within the razor or changed during the DataBound event using the setOptions method.

        .Columns(columns =>
            columns.Bound(p => p.OrderID).Filterable(false);
            columns.Template(@<text></text>).HtmlAttributes(new { @class = "templateCell" }).ClientTemplate(
                    .HtmlAttributes(new { @class = "ProjectStatusStartedClass" })
                    //.Messages(e => e.Checked("Approve").Unchecked("Reject"))  //Approach 1: Can include here in switch
        .Events(e => e.DataBound("onDataBound"))
    function onDataBound(e) {

        //scripts must be evaluated manually 

        //Approach 2: setOptions()    

        //reference all switch elements
        var switchElements = this.tbody.find("input.ProjectStatusStartedClass");  

        //for each element, set the messages
        $(switchElements).each(function (e, switchElement) {  
            var myswitch = $(switchElement).data("kendoSwitch");
                messages: {
                    checked: "approve",
                    unchecked: "reject"

More ASP.NET MVC Grid Resources

See Also

In this article