javascript - Kendo UI 网格和 ng 风格

标签 javascript angularjs kendo-ui kendo-grid ng-style

我有一个 Angular Kendo UI 网格,它正在从我的数据源读取一系列属性。 其中之一包含颜色字符串。我想使用所述颜色字符串来设置网格中方框的背景颜色。

我使用以下盒子模板:

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",
//...
        }
//...
]}

最佳答案

发现问题了。 ng-style 需要采用不同的格式,因为它作为字符串传递给 kendo。

template: "<img class='alarm-box-prediction variable' ng-style=\"{'background-color':dataItem.type}\"></img>",

关于javascript - Kendo UI 网格和 ng 风格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38701510/

相关文章:

javascript - 如何使用 ComboBox 作为 Kendo UI 网格列?

javascript - ionViewWillEnter错误: URI malformed

angularjs - 使用 Protractor 测试临时元素的内容

javascript - 需要计算 AngularJS 中 PageLoad 和单击下一页之间的持续时间

javascript - Protractor - 通过 Protractor 上传文件/运行exe

kendo-ui - 如何获取 Kendo UI 编辑器内容的选定值

javascript - 如何减少 flot graph 和它的 div 容器之间的间距?

javascript - 将 OpenID 与服务器端 JavaScript (node.js) 结合使用,但出现错误

javascript - ExtJs 窗口不显示

javascript - Kendo 模块和 RequireJS (r.js) 表现不佳。 (加载错误)