I've got some code here where I am trying to set a background color of a cell based on the value of the data item: http://dojo.telerik.com/@solidus-flux/eHaMu
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Kendo UI Snippet</title>
<link rel=stylesheet href=http://cdn.kendostatic.com/2014.3.1411/styles/kendo.common.min.css>
<link rel=stylesheet href=http://cdn.kendostatic.com/2014.3.1411/styles/kendo.rtl.min.css>
<link rel=stylesheet href=http://cdn.kendostatic.com/2014.3.1411/styles/kendo.default.min.css>
<link rel=stylesheet href=http://cdn.kendostatic.com/2014.3.1411/styles/kendo.dataviz.min.css>
<link rel=stylesheet href=http://cdn.kendostatic.com/2014.3.1411/styles/kendo.dataviz.default.min.css>
<link rel=stylesheet href=http://cdn.kendostatic.com/2014.3.1411/styles/kendo.mobile.all.min.css>
<script src=http://code.jquery.com/jquery-1.9.1.min.js></script>
<script src=http://cdn.kendostatic.com/2014.3.1411/js/kendo.all.min.js></script>
</head>
<body>
<div id=grid></div>
<script>
$(#grid).kendoGrid({
columns: [ {
field: name,
title: Name,
attributes: function(e) {
return {
class: table-cell,
style: e.name == Jane Doe ? background-color: red : background-color: green
};
}
//attributes: {
//class: table-cell,
//style: text-align: right; font-size: 14px
//}
} ],
dataSource: [ { name: Jane Doe }, { name: John Doe }]
});
</script>
</body>
</html>
I realize I could do this with a template, but that would require an extra html element, since you can't change the markup of the td itself. I'd like to use a function to return attributes if that is supported.