有条件地在 Telerik MVC Grid 中添加复选框

发布于 2025-01-08 08:51:13 字数 365 浏览 2 评论 0原文

我正在使用 Telerik Grid for MVC 3 和 aspx 引擎。我必须仅在状态已完成的那些行上添加一个复选框。

 columns.Bound(grid => grid.CaseStatus).Width(80);

上面是我的绑定列,现在我必须检查 CaseStatus 值是否是某个特定数字,然后我只需在该行中添加复选框。

columns.Add(c => c.CaseID).Title("").Format("<input type='checkbox' />").Encoded(false).Width(5);

知道如何做到这一点吗?

I am using Telerik Grid for MVC 3 with aspx engine. I have to add a check box only on those rows which status are completed.

 columns.Bound(grid => grid.CaseStatus).Width(80);

Above is my bound column now i have to check if CaseStatus value is some specific number then only i have to add check box with that row.

columns.Add(c => c.CaseID).Title("").Format("<input type='checkbox' />").Encoded(false).Width(5);

Any Idea how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美胚控场 2025-01-15 08:51:13

您可以使用 ClientTemplate 来实现此目的:

Exmaple:

columns.Bound(p => p.CaseStatus).Title("Case Status").ClientTemplate("<#= (CaseStatus==true) ? '<input type='checkbox' />' : '' #>");

模板允许您自定义数据在网格中的呈现方式,并且您可以使用 <#= #> 以与服务器端模板类似的方式嵌入和比较数据绑定表达式。

You could use the ClientTemplate to achieve this:

Exmaple:

columns.Bound(p => p.CaseStatus).Title("Case Status").ClientTemplate("<#= (CaseStatus==true) ? '<input type='checkbox' />' : '' #>");

Templates allow you to customise the way the data is presented in the grid and you can use <#= #> to embed and compare databound expressions in a similar way to server side templates.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文