I\'m not understanding something basic about Kendo templates, so maybe someone can explain this to me. This example of a template for a cell in a grid comes from Telerik s
It's JavaScript. Using this template string:
"<input type='checkbox' #= isAdmin ? checked='checked' : '' # />"
Template.compile will generate a function like this one:
function anonymous(data) {
var o, e = kendo.htmlEncode;
with(data) {
o = '<input type=\'checkbox\' ' + (isAdmin ? checked = 'checked' : '') + ' />';
}
return o;
}
As you can see, your template section is used without changes. When your cell is rendered, this function is executed (your data item, e.g. the grid's row model, is passed in) and the resulting string is used as content for the cell.
From the perspective of the rendered HTML, this here:
"<input type='checkbox' #= isAdmin ? checked='checked' : '' # />"
is equivalent to:
"<input type='checkbox' #= isAdmin ? 'checked' : '' # />"
since checked='checked'
will simply evaluate to 'checked'.
Using the first variant however will also set the checked
attribute on the data which is passed into the template function (see demo for illustration).