颜色的细胞的NG-电网的背景与数据RGB值 [英] Color the background of a cell in ng-grid with rgb value in data

查看:160
本文介绍了颜色的细胞的NG-电网的背景与数据RGB值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用纳克电网和我有一个包含以RGB值如#fc3b25等我需要设置每个单元的背景颜色在RGB列于包含在数据库中的值的列的数据库。在libraryGrid,我已经定义了columnDes如下:

I am using ng-grid and I have a database that contains a column with rgb values such as #fc3b25, etc. I need to set the background color of each cell in the rgb column to the value contained in the database. In the libraryGrid, I have defined the columnDes as follows:

{
    field: 'rgb',
    displayName: 'Key',
    width: '50px',
    cellTemplate: "<div style='height:60px; width:50px; background-color: {{ row.getProperty('rgb') }} ;' >rgb</div>"
}

这是行不通的。看来,指令可能是适当的在这里,但我已经没有任何存在任何成功。有什么建议?

This does not work. It seems that a directive might be appropriate here, but I haven't had any success there either. Any suggestions?

推荐答案

撰写您celltemplate是这样的:

Write your celltemplate like this:

{field:'rgb', displayName:'Age', cellTemplate: '<div style="background-color:{{row.entity.rgb}}" ><div class="ngCellText">{{row.getProperty(col.field)}}</div></div>'}]

看看这里工作Plunker

这篇关于颜色的细胞的NG-电网的背景与数据RGB值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆