Css 剑道UI网格Anuglar单元格颜色
我有一个使用剑道UI网格的Angular 2应用程序。在那里我有一个网格显示一些数据(整数值)。是否有可能根据每个单元格的类型对其着色?也许可以根据类型向每个单元格添加css类Css 剑道UI网格Anuglar单元格颜色,css,angular,kendo-ui,kendo-grid,Css,Angular,Kendo Ui,Kendo Grid,我有一个使用剑道UI网格的Angular 2应用程序。在那里我有一个网格显示一些数据(整数值)。是否有可能根据每个单元格的类型对其着色?也许可以根据类型向每个单元格添加css类 现在,数据看起来是这样的[{“a”:4,“b”=35,…},{…},…]我也有每个元素的类型,但还没有保存在数据网格中 我有一个建议,它仍然是纯js剑道的形式(但您应该能够在angular 2剑道中使用schema.parse或angular 2:从后端获取数据后可以在从rest端点检索数据后在中添加额外字段。在循环中添
现在,数据看起来是这样的[{“a”:4,“b”=35,…},{…},…]我也有每个元素的类型,但还没有保存在数据网格中 我有一个建议,它仍然是纯js剑道的形式(但您应该能够在angular 2剑道中使用schema.parse或angular 2:从后端获取数据后可以在从rest端点检索数据后在中添加额外字段。在循环中添加你的逻辑在我的例子中,我只是随机分配颜色
schema: {
parse : function(response){
var colors = [
'red',
'green',
'blue',
'yellow'
];
//loop through all you data, add adding aditional field.
//also here i randomize the color for each cell
for(var i = 0; i< response.d.results.length; i++){
response.d.results[i].cell1 = colors[ Math.floor(Math.random()*colors.length)];
response.d.results[i].cell2 = colors[ Math.floor(Math.random()*colors.length)];
response.d.results[i].cell3 = colors[ Math.floor(Math.random()*colors.length)];
response.d.results[i].cell4 = colors[ Math.floor(Math.random()*colors.length)];
}
return response
}
}
模式:{
解析:函数(响应){
变量颜色=[
“红色”,
“绿色”,
“蓝色”,
“黄色”
];
//循环浏览所有数据,添加其他字段。
//在这里,我还随机选择每个单元格的颜色
对于(变量i=0;i
然后在行模板上,您可以使用它作为类,如下所示(查看cell1、cell2、cell3、cell4属性):
#:FirstName##:LastName#
标题:#:标题#
#:国家#
#:EmployeeID#
然后添加css
<style>
.red {
background-color: red;
}
.green {
background-color: green;
}
.blue {
background-color: blue;
}
.yellow {
background-color: yellow;
}
</style>
瑞德先生{
背景色:红色;
}
格林先生{
背景颜色:绿色;
}
蓝先生{
背景颜色:蓝色;
}
黄先生{
背景颜色:黄色;
}
中的工作示例
<style>
.red {
background-color: red;
}
.green {
background-color: green;
}
.blue {
background-color: blue;
}
.yellow {
background-color: yellow;
}
</style>