jQuery EasyUI 数据网格 - 条件设置行背景颜色

jQuery EasyUI 教程 · 2019-04-06 18:39:42

本教程将向您展示如何根据一些条件改变数据网格(datagrid)组件的行样式。当 listprice 值大于 50 时,我们将为该行设置不同的颜色。

数据网格(datagrid)的 rowStyler 函数的设计目的是允许您自定义行样式。以下代码展示如何改变行样式:

    <table id="tt" title="DataGrid" style="width:600px;height:250px"
            url="data/datagrid_data.json"
            singleSelect="true" fitColumns="true">
        <thead>
            <tr>
                <th field="itemid" width="80">Item ID</th>
                <th field="productid" width="80">Product ID</th>
                <th field="listprice" width="80" align="right">List Price</th>
                <th field="unitcost" width="80" align="right">Unit Cost</th>
                <th field="attr1" width="150">Attribute</th>
                <th field="status" width="60" align="center">Stauts</th>
            </tr>
        </thead>
    </table>
    $('#tt').datagrid({
        rowStyler:function(index,row){
            if (row.listprice>50){
                return 'background-color:pink;color:blue;font-weight:bold;';
            }
        }
    });

正如您所看到的,我们根据一些条件设置 background-color(背景色)为 pink(粉红色),设置文本颜色为 blue(蓝色)。

下载 jQuery EasyUI 实例

jeasyui-datagrid-datagrid18.zip

点击查看所有 jQuery EasyUI 教程 文章: https://codercto.com/courses/l/42.html

查看所有标签

操作系统

操作系统

[美] William Stallings / 陈向群、陈渝 / 电子工业出版社 / 2012-9 / 75.00元

《国外计算机科学教材系列•操作系统:精髓与设计原理(第7版)》是一本关于操作系统的概念、结构和机制的教材,其目的是尽可能清楚和全面地展示现代操作系统的本质和特点;同时,《国外计算机科学教材系列•操作系统:精髓与设计原理(第7版)》也是讲解操作系统的经典教材,不仅系统地讲述了操作系统的基本概念、原理和方法,而且以当代最流行的操作系统——Windows 7、UNIX和Linux为例,全面清楚地展现了当......一起来看看 《操作系统》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具