Kendo Grid Column Template using Javascript

Template pada kendo column dapat menggunakan javascript. Contohnya:

[code language=”javascript”]

function kendoGridImageTemplate(container, options) {
if (container.AbsolutePhoto != null) {
var extFile = container.AbsolutePhoto.split(‘.’).pop();
var extensionImage = ["jpg", "jpeg", "png", "bmp"];

if ($.inArray((extFile).toLowerCase(), extensionImage) !== -1) {
return ‘<a href="’ + container.AbsolutePhoto + ‘" target="_blank"><img src="’ + container.AbsolutePhoto + ‘" alt="" class="img-responsive"></a>’;
}
}
}

//…
columns: [
//…
{
field: "Photo",
title: "Gambar",
template: kendoGridImageTemplate,
filterable: false,
sortable: false,
width: 200,
},
//…
],
[/code]

Chandra Oemaryadi has written 244 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>