Kendo UI grid URL Column

Piyush picture Piyush · Jun 5, 2014 · Viewed 17.3k times · Source

I want to add a hyperlink in my Kendo UI Grid. from data source I am getting a URL back and I just want to to display it as a hyperlink . below is a sample code . Please suggest me the simplest way to do that.

 <div id="testGrid" data-role="grid" data-bind="source: sampleData"
data-sortable="true"  data-resizable="true" />

$(document).ready(function(){
var sampleData = [
    { "Title": "The Code Project", "URL": "http://codeproject.com/","Developer":"Tom Hanks" },
    { "Title": "Kendo UI", "URL": "http://kendoui.com/" ,"Developer":"Tom Cruise"}
];
var ddatasource=  new kendo.data.DataSource.create(sampleData);
$("#testGrid").kendoGrid({
    dataSource: ddatasource,
    columns: [{ field: "Title", title: "Title Name"},
              { field: "URL", title: "URL :"}]
});
});

Answer

Rick S picture Rick S · Jun 5, 2014

You can do this with a template:

columns: [{ field: "Title", title: "Title Name"},
          { field: "URL", title: "URL :", template: '<a href="#=URL#">#=Title#</a>'}]

You can try it out on the Kendo Dojo here: http://trykendoui.telerik.com/aFAR