如何在 Telerik 网格中插入下拉列表框

发布于 2024-09-24 19:12:50 字数 94 浏览 1 评论 0原文

我有一个 Telerik 网格,有两列,我需要将第二列保留为网格中的下拉列表框,我正在使用 ASP.NET MVC 控件

任何人都可以告诉我如何执行此操作吗?

I have a Telerik Grid, with two columns I need to keep second column as drop-down list box with in the grid, I am using ASP.NET MVC control

Can any body tell me how to do this?

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

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

发布评论

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

评论(2

复古式 2024-10-01 19:12:50

我需要为我的项目这样做。
我是这样做的:

columns.Bound(o => o.Role).ClientTemplate(
                Html.Telerik().DropDownList()
                    .Name("RoleList<#= UserID #>")
                    .BindTo(new SelectList(UserController.GetRoles()))
                    .ToHtmlString()
            );

静态方法GetRoles返回String的简单IEnumerable。您仍然可以通过使用不同的 SelectList 构造函数来指定自定义对象的 ValueText 属性来返回自定义对象。

new SelectList(UserController.GetCustomRoles(), "RoleID", "ShortName")

I need to do that for my project.
Here is how I did it:

columns.Bound(o => o.Role).ClientTemplate(
                Html.Telerik().DropDownList()
                    .Name("RoleList<#= UserID #>")
                    .BindTo(new SelectList(UserController.GetRoles()))
                    .ToHtmlString()
            );

The static method GetRoles returns a simple IEnumerable of String. You still can return a custom object by using a different SelectList constructor to specify Value and Text property of your custom object.

new SelectList(UserController.GetCustomRoles(), "RoleID", "ShortName")
笑脸一如从前 2024-10-01 19:12:50

您可以设置列的模板以嵌入任意 HTML。如果使用 Ajax 绑定 - 尝试客户端模板。以下在线示例会有所帮助:

  1. 服务器模板
  2. 客户端模板

You can set the template of the column to embed arbitrary HTML. If using Ajax binding - try the client template. The following online examples will be helpful:

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