lundi 9 octobre 2017

How can i implement condition statements on Client Template on Kendo

I have permissionId which i am reading it from config file and then bind it to the model. It is a static Id of 100. So i want to write a condition based on the permissionId. If user got permissionId 100,It must show delete link on kendo grid column and if it not 100, it must not show delete link. it must be blank. Now am not getting the conditions correct and not sure it my model it is returning permissionId or not.

Please point me to the right direction.

What i have done;

Grid

 @(Html.Kendo().Grid<myModel>()
            .Name("Grid")
                  .Columns(columns =>
                  {

                    columns.Template(@<text>@Html.ActionLink(@item.ReportID.ToString(), "", "", new { ReportID = @item.ReportID }) </text>)
                                .ClientTemplate("# if (deletePermissionId == @Model.deletePermissionId ){ #" +
                                  "<a href='\\#' onclick=\"functionDeleteReport('#=ReportID#')\">Delete</a>" + "#}" +
                                "else { #" + "<img src='~/Content/Logo/imageedit_1_5371617138.png' alt='' />" +
                                "# } #");

                      columns.Bound(x => x.deletePermissionId).Title("Permission Id").Hidden(true);

                  })
                  .Pageable(pageable => pageable
                    .Refresh(true)
                    .PageSizes(true)
                    .ButtonCount(5))
                  .Scrollable()
                  .Filterable()
                  .Sortable()
                  .Resizable(resize => resize.Columns(true))
                  .DataSource(dataSource => dataSource
                  .Ajax()
                  .PageSize(10)
                  .ServerOperation(false) //No post back
                  .Read(read => read.Action("Delete", "Delete"))))

Aucun commentaire:

Enregistrer un commentaire