这对我来说很奇怪,但cshtml
视图:
@{
var platformsClientTemplate = @"
# var names = []; for(int i=0; i<Platforms.length; i++) { names.push(Platforms[i].Name);} #
#= names.join(', ') # ";
}
@(
Html.Kendo().Grid<ApplicationUserViewModel>()
.Columns(cols =>
{
// ...
cols.Bound(u => u.Platforms).ClientTemplate(platformsClientTemplate).Width(300);
// ...
}
// ...
)
转换为此客户端的html(“查看源代码”):
jQuery(function(){jQuery("#UsersGrid").kendoGrid({"columns":[
// ....
{ title: "mytitle",
//...
"template":" # var names = []; for(int i=0; i\u003cPlatforms.length; i ) { names.push(Platforms[i]);} # #= names.join(\u0027, \u0027) # "
}
//...
]});
看起来'++'删除是错误的。如何在不使用forEach
等新方法的情况下枚举此客户端模板中的模型?