开发者

Telerik MVC Grid : Putting a button in a column

What im trying to do is have an edit button that instead of opening the line for editing, it forwards you to a page where you can edit. Is th开发者_JS百科is possible? I tried something with the client template, but the grid render is ignoring it completely.


Yes, you can place a component into a grid column. Heres an example of how I bound the Id column with an Action link to the edit action passing in the Id.

I've removed the other columns from the template for clarity.

        Html.Telerik().Grid(Model)
            .Name("Items")
            .DataKeys(keys => { keys.Add(x => x.Id); })
            .Columns(columns =>
            {
                columns.Bound(x => x.Id).Title("").Format(Html.ActionLink("edit", "Edit", new { id = "{0}" }).ToHtmlString()).Encoded(false).Width(60);
            })
            .Render();


You can use Template method instead:

@(Html.Telerik().Grid(Model)
      .Name("Items")
      .DataKeys(keys => { keys.Add(x => x.Id); })
      .Columns(columns =>
      {
          columns.Bound(x => x.Id)
                 .Title("")
                 .Template(@Html.ActionLink("edit", "Edit", new { x.id }))
                 .Width(60);
      })
)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜