jquery - 如何使用属性根据数据更改剑道网格行颜色背景
问题描述
在我的剑道网格中,我可以使用以下方法更改单元格的颜色,但不能更改行的颜色。
对于值为 的所有事件,我得到绿色rainy
,但红色仅适用于单元格而不适用于行。我怎么能得到那个?
$("#grid").kendoGrid({
dataSource: myDB,
height: 550,
{
field: "User",
title: "User",
width: "50px",
},
{
field: "WindSpeed",
title: "Wind Speed",
width: "40px"
},
{
field: "EventName",
title: "Event Type",
width: "50px",
attributes: {
" class": "# if(data.EventName === 'rainy') { # green # } else { # white # }, #"
},
}
}
解决方案
dataBound
您可以在活动中实现这一点。
var grid = $("#grid").data("kendoGrid");
grid.bind("dataBound", grid_dataBound);
grid.dataSource.fetch();
function grid_dataBound(e) {
var items = e.sender.items();
items.each(function (index) {
var dataItem = grid.dataItem(this);
if (dataItem.age > 32) {
this.className += " customClass1";
}
else {
this.className += " customClass2";
}
})
}
Dojo 示例: 有条件地更改 Kendo Grid Row 颜色
推荐阅读
- algorithm - 如何从 T(n) = T(n/2) + n 得到 O(n)?
- java - Spring Boot:文件上传测试
- node.js - 立即禁用单个 nock 范围以重新设置模拟 URL
- javascript - 如何在Angular的另一个类中扩展一个类
- oracle - “declare”适用于 sqlplus 和 sql developer,但为什么不适用于 sql navigator?
- sql - 红移时间在 2 倍之间
- excel - 基于列值的条件格式
- javascript - 如何捕获来自多个功能的拒绝?
- java - 如何在java4中解析json文件作为输入
- angular - Angular Google Maps 航路点不与动态航路点数组一起显示