我有一个角度的 Kendo UI Grid,它正在从我的数据源中读取一系列属性。其中一个包含一个颜色字符串。我想使用所述颜色字符串为网格中的方框设置背景颜色。
我正在为该框使用以下模板:
template: "<img class='alarm-box-prediction variable' ng-style={'background-color': dataItem.type}'></img>"
我的数据源中的相关数据如下:
dataSource: {
dataSource: function(data) {
// Map the stored properties in the data array of objects received to
// their corresponding columns in the Grid
return $.map(data, function(alarmProperty) {
return {
// Change array index to match API once we are getting data from there
type: alarmProperty[0],
//... there are more properties here but i removed them as they are not the focus
};
});
},
与当前用作我的 DS 的 JSON 文件相关的数据(不过很快会更改)是:
{
"alarms": [
{
"type": "Yellow",
//...
}
//...
]}