Enable Disable KendoGrid buttons base on condition in ASP.Net MVC

mahesh213
 
on Sep 24, 2021 03:00 AM
596 Views

Hi

How to enable disable create edit buttons based upon session value

I have one grid and i have stored one session value

Session["Name"]="Admin"

Currently my requirement is that if Session is Admin then only i need to enable create and edit button

Can you please help me

{
    Layout = null;
}
 
@using AspProject.Models; 
@using Kendo.Mvc.UI;
 
@(Html.Kendo().Grid<License>()
      .Name("inlineGrid")
      .Columns(columns =>
      {
          columns.Bound(p => p.LicenseId).Width(20).Hidden().HeaderHtmlAttributes(new { @title = "License" });
 
          columns.Bound(p => p.LicenceName).Width(20).Width(300);
          columns.Bound(p => p.Licencedate).Width(20).HeaderHtmlAttributes(new { @title = "Vendor" }).Width(300);
           
          columns.Command(p => p.Edit().Text("Edit").HtmlAttributes(new { @title = "Edit" })).Width(220);
      })
      .ToolBar(toolbar => toolbar.Create().Text("Add").HtmlAttributes(new { @title = "Add" }))
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .Pageable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .Model(model => model.Id(p => p.LicenseId))
              .Read(read => read.Action("Read", "Home").Type(HttpVerbs.Post))
              .Update(update => update.Action("Update", "Home").Type(HttpVerbs.Post))
          )
)
Download FREE API for Word, Excel and PDF in ASP.Net: Download