Conditionals embedded in client templates in kendo ui MVC grid (server)

11,025

Solved it.this may help others facing same problem

@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
  columns.Bound(o => o.AccountManager).Title("Account Manager").ClientTemplate("# if (AccountManager == null) { #" + @Html.ActionLink("Assign", "action", "Controller", new { @caseId = "#=CaseID#", @tabIndex = "0" }, new { @Title = "View"}).ToHtmlString() + "# }else {#" +  "#=AccountManager#" + "#} #").HtmlAttributes(new {@style = "text-align:center" });  
})
Share:
11,025
amol
Author by

amol

Updated on June 11, 2022

Comments

  • amol
    amol about 2 years

    Inside a Kendo Grid, I'd like to display a link to the user if manager is not assigned , else display the name of manager already assigned . as the manager can be null, I'm having success getting this link to only show when the manager is not null. but problem is if manager is not null how to diaplay the manager name in else part

    Below is the client template I'm trying to use:

    @(Html.Kendo().Grid(Model)    
     .Name("Grid")
     .Columns(columns =>
     {
         columns.Bound(o => o.AccountManager).Title("Account Manager")
        .ClientTemplate("# if (AccountManager == null) { #" + @Html.ActionLink("Assign", "action", "Controller", new { @caseId = "#=CaseID#", @tabIndex = "0" }, new { @Title = "View"}).ToHtmlString() + "# }else {#" + "how to dispaly value of account manager here" + "#} #").HtmlAttributes(new {@style = "text-align:center" });  
     })       
    
  • gyosifov
    gyosifov over 9 years
    This article might also help "Execute arbitrary Javascript code": docs.telerik.com/kendo-ui/framework/templates/overview