Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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);
      })
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top