如何根据 Kendo UI Grid 中行的值更改行的颜色 [英] How to change color of row depending on a row's value in a Kendo UI Grid
本文介绍了如何根据 Kendo UI Grid 中行的值更改行的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 Kendo UI 网格,其中包含四列:
I have a Kendo UI Grid, which contains four columns:
Highlight MAC Time Message
Highlight
列可以包含值yes"或no",并且该列是隐藏的.
The Highlight
column can contain the values "yes" or "no", and this column is hidden.
如果值为 yes,我需要创建一个行模板,该模板将突出显示(更改颜色或其他内容)该行.
I need to create a row template that will highlight (change the color or something) the row if the value is yes.
推荐答案
您可以在行模板中应用条件,尝试类似下面的内容
You can apply condition in Row Template, Try Something like below
$("#grid").kendoGrid({
dataSource: ds,
rowTemplate: '<tr class="#:Highlight =="Yes"? "red" : "white"#" data-uid="#= uid #"><td>#: MAC #</td><td>#:Time #</td><td>#:Message#</td></tr>'
});
数据源
var ds = new kendo.data.DataSource({
data: [{
Highlight : "Yes",
MAC :"...",
Time :"...",
Message:"...."
}, {
Highlight : "No",
MAC :"...",
Time :"...",
Message:"...."
}]
});
这篇关于如何根据 Kendo UI Grid 中行的值更改行的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文