Sveta Antrapovich
Sveta Antrapovich

Reputation: 417

Kendo UI Grid add link

I want data in my column to be link to another page.

columns.Bound(p => p.Name).Title("Name");

How can I do this?

Upvotes: 0

Views: 1827

Answers (2)

DontVoteMeDown
DontVoteMeDown

Reputation: 21465

Try this:

columns
    .Bound(p => p.Name)
    .Title("Name")
    .ClientTemplate("<a href='external/page/url'>#:Name#</a>")

Docs for ClientTemplate.

You also mix it with Html.ActionLink:

.ClientTemplate(@Html.ActionLink("#:Name#"))

To change the action and/or the controller, add the 2nd and 3rd params to it:

.ClientTemplate(@Html.ActionLink("#:Name#", "Action", "Controller"))

If you wanna pass any data through the url, use the route parameters as the 4th param:

.ClientTemplate(@Html.ActionLink("#:Name#", "Action", "Controller", new { id = p.Id }))

The ActionLink helper will produce a link the as the string I proposed above, with the text being #:Name which is what the template will understand as the your Name property in the row.

Upvotes: 2

calinaadi
calinaadi

Reputation: 1466

It should be something like:

   column.Template(p => @Html.ActionLink("Title", "Method", "Controller", new { id = p.propId, }));

More details: http://www.telerik.com/forums/kendo-mvc-grid-actionlink-column

Upvotes: 1

Related Questions