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

Hide Edit command conditionally

0 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mirza
Top achievements
Rank 1
Iron
Mirza asked on 29 Jan 2021, 12:26 AM

I'm trying to conditionally hide the Edit and Destroy command buttons in my Grid but I haven't had much luck figuring out how to do that. Below is the code I currently have. I saw an example on the Telerik UI ASP.NET Core forum for how to do this and it involves using the Visible() method with a handler. However, that is apparently not available in Telerik UI ASP.NET AJAX. Is there something similar that will let me accomplish this?

@(Html.Kendo().Grid<MyViewModel>()
  .Name("MyGrid")
  .Columns(columns =>
  {
    ...
    columns
      .Command(command =>
      {
        command.Edit()
        .Text("Edit Me")
        .Visible("IsEditVisible"); // this is not supported
      }
    )
    .Width("125px");
  }
)
...
<script>
function IsEditVisible(dataItem){
  return dataItem.CanEdit;
}     

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Mirza
Top achievements
Rank 1
Iron
Share this question
or