Template column with an anchor tag or other hyperlink example

1 Answer 3374 Views
Grid
Todd
Top achievements
Rank 1
Todd asked on 30 Dec 2011, 03:21 PM
Do anyone have an example of template column that uses a data field to build a url?

1 Answer, 1 is accepted

Sort by
0
Todd
Top achievements
Rank 1
answered on 30 Dec 2011, 03:49 PM
Answered my own question.

 template:'<a href="#=StudentId#">Details</a>'
RMC
Top achievements
Rank 1
commented on 09 Jan 2012, 08:02 PM

if the anchor has # in the link, you have to scape it with two back slash \\#
Phillip
Top achievements
Rank 2
commented on 09 May 2012, 05:12 PM

I refined this a bit. The following provides a hyperlink to a grid item with absolute path and a required ID field "WorkId" to be included in the URL. I also use the field "WorkDescriptor" as the display name.

columns: [
                { field: "WorkDescriptor", title: "Song Reference Name", width: 200, template: '<a href="/Song/Details?id=#=WorkId#">#=WorkDescriptor#</a>' }
} ]
Tags
Grid
Asked by
Todd
Top achievements
Rank 1
Answers by
Todd
Top achievements
Rank 1
Share this question
or