I have this dojo with its inline template
var actionName = 'read';
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
dataSource: [
{ name: "Jane Doe", age: 30, read: true, actionName: actionName }
],
detailTemplate: "<div> #:" + actionName +"# </div>"
});
and this dojo with its external template:
<script id="detailTemplate" type="text/x-kendo-template">
#: actionName #
</script>
var actionName = 'read';
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
dataSource: [
{ name: "Jane Doe", age: 30, read: true, actionName: actionName }
],
detailTemplate: function(dataItem){
return kendo.template($("#detailTemplate").html())(dataItem);
}
});
In first one detailTemplate: "<div> #:" + actionName +"# </div>"
I can render value: true
however in second one wiht #: actionName #
I can render read
.
So my question how can I render to value true
The parametr (which you named) dataItem takes over data from current row. Then you need to write property which you want to render. dataItem is valid for whole template.
and
should be enough.
Dojo example
Parameter of function in detailTemplate will contains all properties from object in row (even not visible as column). So if you will do some special calculations or something you can do it in detailtemplate function and create new property which will be accesible by name in template.
Dojo example 2
Edit: If you want run (let's say) some command, which is in string you have to use eval function. This function will execute the text. It means if you will use some functuion name as eval parameter, this function will be executed.
Dojo example 3
Yet, I dare to quote one important paragrapg from this site: eval - mozila developer