John Stuart
John Stuart

Reputation: 333

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

Upvotes: 0

Views: 6085

Answers (2)

alx
alx

Reputation: 21

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);
      })
)

Upvotes: 2

Kelly Ethridge
Kelly Ethridge

Reputation: 1678

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();

Upvotes: 6

Related Questions