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

Command button disabling

1 Answer 762 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Attila
Top achievements
Rank 2
Attila asked on 03 Oct 2017, 01:04 PM

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

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 05 Oct 2017, 06:56 AM
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.
Tags
Grid
Asked by
Attila
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Share this question
or