Command button disabling

2 posts, 1 answers
  1. Attila
    Attila avatar
    22 posts
    Member since:
    Oct 2016

    Posted 03 Oct 2017 Link to this post


    Is there any way to disable a command.Edit() or a command.Destroy() button? I don't want to hide them, the user should see there's an option for both functions, but I want to disable them depending on the @User.IsInRole("RoleName") status. I tried several ways: using Javascript and adding k-state-disabled class will make them disabled-look but they are still clickable. I also tried this way:

    .Columns(columns => columns.Command(command=>{command.Edit().HtmlAttributes(new {@class = @User.IsInRole("RoleName") ? "k-state-disabled" : ""});


    but same result as Javascript result: stays clickable but they are grayed out.

    Thanks for your help

  2. Answer
    Stefan avatar
    2475 posts

    Posted 05 Oct 2017 Link to this post

    Hello, Attila,

    The desired result can be achieved by setting the "k-state-disabled" class and removing the delete and edit specific classes only on the disabled buttons. This can be achieved on the dataBound event using jQuery:

    I hope this is helpful.

    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top