如何在Kendo UI网格中根据行的值更改行的颜色 [英] How to change color of row depending on a row's value in a Kendo UI Grid

查看:56
本文介绍了如何在Kendo UI网格中根据行的值更改行的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Kendo UI网格,其中包含四列:

I have a Kendo UI Grid, which contains four columns:

Highlight  MAC   Time  Message

Highlight列可以包含值是"或否",并且此列是隐藏的.

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网格中根据行的值更改行的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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