开发者

How to insert drop down list box in a Telerik grid

开发者 https://www.devze.com 2023-01-16 17:13 出处:网络
I have a Telerik Grid, w开发者_如何学Goith two columns I need to keep second column as drop-down list box with in the grid, I am using ASP.NET MVC control

I have a Telerik Grid, w开发者_如何学Goith 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?


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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消