Kendo UI Grid和ng风格
问题描述:
我有一个角度为Kendo UI Grid,它从我的数据源读取一系列属性。 其中之一包含一个颜色字符串。我想使用上述颜色字符串来为网格中的方框设置背景颜色。Kendo UI Grid和ng风格
我使用的盒子下面的模板:
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
};
});
},
从JSON文件,该文件是当前服务相关的数据因为我的DS(即将更改)是:
{
"alarms": [
{
"type": "Yellow",
//...
}
//...
]}
答
找到了问题。 ng样式需要以不同的格式进行格式化,因为它作为字符串传递给kendo。
template: "<img class='alarm-box-prediction variable' ng-style=\"{'background-color':dataItem.type}\"></img>",