gpt4 book ai didi

jquery - 如何使用属性根据数据更改 Kendo 网格行颜色背景

转载 作者:行者123 更新时间:2023-12-01 04:35:43 27 4
gpt4 key购买 nike

在我的剑道网格中,我可以使用以下方法更改单元格的颜色,但不能更改行的颜色。

对于所有值为 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 示例: Change Kendo Grid Row color conditionally

关于jquery - 如何使用属性根据数据更改 Kendo 网格行颜色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56751663/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com