Conditionals embedded in client templates in kendo

2019-07-20 12:22发布

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" });  
 })       

1条回答
Animai°情兽
2楼-- · 2019-07-20 13:09

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" });  
})
查看更多
登录 后发表回答