Friday, March 01, 2013

KendoUI Grid MVC4 hide delete button in the list if there is depent records




.CellAction(cell=>{
                     if (cell.Column.Title == "Delete" && cell.DataItem.ChildRecords.Count > 0)
                     {
                         cell.HtmlAttributes["style"] = "visibility:hidden";
                     }
                 })

alternatively:


columns.Template(
                          @@Html.ActionLink("Delete", "Delete", new { id = item.ChildRecordId}, (item.ChildRecords.Count > 0 ? new {style = "display: none"} : null))
                          ).Title("Delete");

No comments: