This is a migrated thread and some comments may be shown as answers.

Change the button text on command.Custom

1 Answer 829 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Russell
Top achievements
Rank 1
Russell asked on 18 Nov 2016, 06:11 PM

Hello,

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);

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 22 Nov 2016, 12:37 PM
Hello Russell,

You can use the items() method of the grid to achieve this requirement:
http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-items


For example:
Copy Code
columns.Command(command =>
{
    command.Custom("Creating").Click("CreateOrderCmd")
    .HtmlAttributes(new { @class = "creatingButtonClass" });
Grid event:
Copy Code
.Events(e => e.DataBound("gridDataBound"))
JavaScript:
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") {
            button.hide();
        }
    });
}

Alternatively, you can use Templates with condition:
http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/faq#how-to-apply-conditional-logic-in-column-client-templates

I hope this will prove helpful.


Regards,
Eyup
Telerik by Progress
Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Russell
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or