How to insert drop down list box in a Telerik grid

£可爱£侵袭症+ 提交于 2019-12-29 07:19:09

问题


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?


回答1:


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



回答2:


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


来源:https://stackoverflow.com/questions/3752182/how-to-insert-drop-down-list-box-in-a-telerik-grid

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