Command button disabling

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

    Posted 03 Oct Link to this post

    Hi!

    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
    Admin
    Stefan avatar
    1153 posts

    Posted 05 Oct 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:

    http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-dataBound

    https://dojo.telerik.com/ERuTot

    I hope this is helpful.

    Regards,
    Stefan
    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