My Kendo UI grid is dynamic, where the columns can be defined as field0
, field1
through field[n]
; I do NOT know the number
I think it will be hard to sync the columns with the column headers if you use a row template. What I'd do is use a dynamically created client template and place the business logic inside that one instead.
function getTemplate(field, fieldName){
var color;
if(field[fieldName] > 4000000){
color = "green";
}else{
color = "red";
}
return "" + field[fieldName] + "";
}
vm.userGridOptions = {
selectable: true,
sortable: true,
pageable: true,
columns: [
{ field: "field0" },
{ field: "field1",
template: (function(dataItem){
return getTemplate(dataItem, "field1");
})
},
Example:
http://plnkr.co/edit/lPUzfu?p=preview