Conditionally disable custom command button

2 posts, 0 answers
  1. Jim Collier
    Jim Collier avatar
    4 posts
    Member since:
    Oct 2003

    Posted 12 Feb 2016 Link to this post

    I would like to conditionally disable custom command button when a specific value existing in a column field.

                    .Events(e => e.DataBound("commandButtons"))
                    .Columns(columns =>
                        columns.Bound(c => c.Customer).Title("Customer");
                        columns.Bound(c => c.CustomerID).Title("Customer #").Sortable(false).Width(100);
                        columns.Bound(c => c.EquipmentID).Title("Equipment #").Sortable(false).Width(100);
                        columns.Bound(c => c.AlarmCode).Title("Alarm").Sortable(false).Width(75);
                        columns.Bound(c => c.AltAlarmDescription).Title("Description").Sortable(false);
                        columns.Bound(c => c.FirstAlarmDateLocal).Title("Alarm Date").Format("{0:MM/dd/yy hh:mm:ss tt}").Width(175);
                        columns.Bound(c => c.AlarmCount).Title("Count").Sortable(false).Width(75);
                        columns.Bound(c => c.AssignedTo).Title("Assigned To").Sortable(false).Width(175);
                        columns.Command(command => command.Custom("Assign").Click("assignAlarm")).Width(100);
                        columns.Command(command => command.Custom("Auto Case").Click("showResolveWindow")).Width(100);
                        columns.Command(command => command.Custom("Manual Case").Click("createSfdcAlarmCase")).Width(100);

     When c.AssignedTo == "" I would like to disable the Auto Case and Manual Case buttons.  It is not clear to me how to accomplish this with a custom command.




  2. Dimiter Madjarov
    Dimiter Madjarov avatar
    2213 posts

    Posted 16 Feb 2016 Link to this post

    Hello Jim,

    There is no configuration option for disabling custom commands. A visually disabled style could be applied in the dataBound event handler of the Grid by iterating it's items.

    columns.Command(c => c.Custom("customCommand"));

    .Events(e => e.DataBound("dataBound"))

    function dataBound(e) {
        var grid = this;
        grid.tbody.find("tr[role='row']").each(function () {
            var model = grid.dataItem(this);
            if (model.Freight > 20) {

    Nevertheless this will not prevent the custom handler for the command to be executed. You should perform similar check in the command click handler.

    Dimiter Madjarov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top