Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo UI grid URL Column

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 :"}]
});
});
like image 231
Piyush Avatar asked Jun 05 '14 15:06

Piyush


1 Answers

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

like image 70
Rick S Avatar answered Sep 17 '22 20:09

Rick S