Dear KendoUI team,
my grid displays data delivered from a JSONP webservice.
Rather than extending the webservice model
I would like to tweak a column on the client side to show an <img> depending on the value of another property in the model.
So, how can I show an <img> which' src depends on the value of another property in the model?
For instance:
the service model has a
Thank you in advance,
Hermann
my grid displays data delivered from a JSONP webservice.
Rather than extending the webservice model
I would like to tweak a column on the client side to show an <img> depending on the value of another property in the model.
So, how can I show an <img> which' src depends on the value of another property in the model?
For instance:
the service model has a
- Name (string)
- IsValid (boolean)
- Count (number)
property.
Column definitions in the grid look like:
columns:[
{field:"Name", title:"Product"},
{field:"IsValid", title: "State"}
]
What I actually want is a column that should behave like:
{field:"IsValid", title: "State"
, template: {
function(model) {
if(model.IsValid && model.Count > 0)
return "<img src ='images/good.png'/>";
else return "<img src ='images/bad.png''/>";
}
}
}
According to the - much better - documentation, "template" property expects a string, but is it possible to add some JavaScript code to the template string as well, something like
var imgTemplate = kendo.template(
"#if (model.IsValid && model.Count > 0){#<img src='icons/A.png'/>#}#else {#<img src='icons/B.png'/>#}
#");
and in the columns definitiontemplate: imgTemplate(model)
Thank you in advance,
Hermann