Hi,
The Kendo UI Grid has the ability to conditionally hide/show the command columns. But in order to hide some buttons from the toolbar, you need a dataBound handler. It will be useful to hide the "Create" button from non-admins, but be able to show the PDF and Excel Export or hide the entire toolbar.
toolbar: [
{ name:
"create"
, visible:
function
(){
return
isAdmin; } },
{ name:
"reports"
, visible:
function
(){
return
isManager }},
{ name:
"cancel"
}
],
.Events(e=>e.DataBound(
"onDataBound"
))
function
onDataBound(e) {
if
(
true
) {
// the condition against which you want to show/hide the toolbar
this
.element.find(
".k-grid-toolbar"
).hide();
// hides the entire toolbar
this
.element.find(
".k-grid-add"
).hide();
// hides just the Create button
}
}
Hi,
For the ASP.NET MVC and Core Grid, we can add a condition:
@{
// check if the user should have access
var isAdmin = false;
}
.ToolBar(t =>
{
if (isAdmin)
{
t.Create();
t.Pdf();
}
else
{
t.Pdf();
}
})
The other option is to use a ToolBar template and pass a condition there. This approach is also valid for the jQuery Grid:
http://demos.telerik.com/aspnet-mvc/grid/toolbar-template
I will mark this item as Unplanned and if it gains enough popularity, the Product Management team will consider it for future implementation.
Thank you both for taking the time to share your thoughts.
Regards,
Alex Hajigeorgieva
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.