My Kendo UI grid is dynamic, where the columns can be defined as field0
, field1
through field[n]
; I do NOT know the number of fields ahead of time.
I would like to use the rowTemplate
in order to apply css background-color
to the <td>
cell.
Further details:
Each cell value must be sent to a ratio function (i.e. the financial risk exposure divided by a benchmark value). The result of that ratio determines the background-color property from that cell).
I'm starting with this code snippet, and I am working on this plunker: http://plnkr.co/edit/wAeJZz8xGeNupsA3rVMA?p=preview
var gridOptions = {
dataSource: ds,
pageable: true,
columnMenu: true,
resizable: true,
columns: heatMapColDefs ,
dataBound: function (e) {
}
, rowTemplate: function (row) {
// HOW TO DETERMINE THE TD CELL VALUE AND APPLY A BACKGROUND-COLOR DYNAMICALLY ???
}
};
Your advice is appreciated...
Bob
By looking at the first row of data from the datasource, you can iterate the properties to get all the fields and build dynamically the columns and row template of the grid and the model fields of the dataSource:
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.
Example:
http://plnkr.co/edit/lPUzfu?p=preview