【发布时间】:2018-10-11 17:41:09
【问题描述】:
使用 Kendo UI MVC 已经有一段时间了,需要在网格的一个字段中的复选框上放置一些条件逻辑。
网格中需要评估的字段是
在此处停止示例
https://docs.telerik.com/aspnet-mvc/helpers/grid/faq#how-to-display-checkboxes-in-ajax-bound-grids
columns.Bound(p => p.ProductName).ClientTemplate(
"# if (HasIcon == true) { #" +
"<img src='" + Url.Content("~/Content/icons/") + "#= ProductID #.png' alt='#= ProductName # icon' />" +
"# } else { #" +
"#: ProductName #" +
"# } #"
);
如何格式化条件内的测试以使用网格字段值?
例如
测试 ProductID 是否是这样的特定值?
columns.Bound(p => p.ProductName).ClientTemplate(
"# if (#= ProductID # == 123) { #" +
"<img src='" + Url.Content("~/Content/icons/") + "#= ProductID #.png' alt='#= ProductName # icon' />" +
"# } else { #" +
"#: ProductName #" +
"# } #"
);
【问题讨论】:
标签: kendo-grid kendo-asp.net-mvc