Change the button text on command.Custom

2 posts, 0 answers
  1. Russell
    Russell avatar
    3 posts
    Member since:
    Jul 2016

    Posted 18 Nov 2016 Link to this post


    I have a custom command column in my grid as seen below.  I would like to change the text of the button from "Activate" to "Deactivate" based on 2 other cells values in the row.  How can I do this?  Thanks.

    col.Command(command => command.Custom("Activate").Click("activate_deactivate")).Locked(true).Width(140);
  2. Eyup
    Eyup avatar
    4081 posts

    Posted 22 Nov 2016 Link to this post

    Hello Russell,

    You can use the items() method of the grid to achieve this requirement:

    For example:
    Copy Code
    columns.Command(command =>
        .HtmlAttributes(new { @class = "creatingButtonClass" });
    Grid event:
    Copy Code
    .Events(e => e.DataBound("gridDataBound"))
    Copy Code
    function gridDataBound(e) {
        var grid = this;
        grid.items().each(function (i, item) {
            var value = grid.dataItem(item).ProductName;
            var button = $(item).find(".creatingButtonClass");
            if (value == "Chang") {

    Alternatively, you can use Templates with condition:

    I hope this will prove helpful.

    Telerik by Progress
    Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
Back to Top