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

依然范特西╮ 提交于 2019-12-24 00:35:37

问题


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:


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


来源:https://stackoverflow.com/questions/18786962/conditionals-embedded-in-client-templates-in-kendo-ui-mvc-grid-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!