0

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 this possible? I tried something with the client template, but the grid render is ignoring it completely.

John Stuart
  • 333
  • 8
  • 23
  • http://stackoverflow.com/questions/2243898/displaying-standard-datatables-in-mvc w/ Model strongly typed as System.Data.DataTable – Madhu BK Apr 30 '15 at 05:47

2 Answers2

6

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();
Kelly Ethridge
  • 1,669
  • 1
  • 11
  • 12
2

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);
      })
)
alx
  • 21
  • 1