数据网格(datagrid)的 rowStyler 函数的设计目的是允许您自定义行样式

rowStyler 函数需要两个参数:

  • rowIndex:行的索引,从 0 开始。
  • rowData:该行相应的记录。

查询用户并设置不允许收费的用户背景色突出显示

function onReady(){
$('#basicInfoList').datagrid("options").url=rootpath+"/queryPageListBySql?sqlKey=com.online.charge.customer.jccustomer.mapper.JcCustomerExtendsMapper.selectAllList";
var conditions = [];
gridLoad(conditions,null);
showColor();
} //不允许收费显示背景色
function showColor(){
$('#basicInfoList').datagrid({
rowStyler:function(index,row){
if (row.isAllowCharge == "0" || row.isAllowCharge == 0){
return 'background-color:#668B8B;';
}
}
});
}

效果如下

http://www.jeasyui.net/tutorial/42.html

顺便总结一下常用的定义的格式化函数

formatter 单元格的格式化函数,需要三个参数:

  • value:字段的值。
  • rowData:行的记录数据。
  • rowIndex:行的索引。
formatter : function(value, row, index) {
//split函数就是以""内的符号为分割依据
var ret = value.split("");
//判断长度是否超过自己预定义的值
if (ret.length > 16) {
//长度超过后截取自己想要显示的字符串,其余的以...显示
value = value.substring(0, 15) + "...";
}
//返回组装后的值
return value;
}

styler 单元格的样式函数,返回样式字符串来自定义该单元格的样式,例如 'background:red' 。该函数需要三个参数:

  • value:字段的值。
  • rowData:行的记录数据。
  • rowIndex:行的索引。
$('#dg').datagrid({
columns:[[
{field:'listprice',title:'List Price', width:80, align:'right',
styler: function(value,row,index){
if (value < 20){
return 'background-color:#ffee00;color:red;';
// the function can return predefined css class and inline style
// return {class:'c1',style:'color:red'}
}
}
}
]]
});

EasyUI 条件设置行背景颜色的更多相关文章

  1. 雷林鹏分享:jQuery EasyUI 数据网格 - 条件设置行背景颜色

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

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

    $('#tt').datagrid({ rowStyler:function(index,row){ if (row.listprice>50){ return 'color:blue;font ...

  3. [ASP.NET] [JS] GridView点击高亮当前选择行,并在点击另一行时恢复上一选择行背景颜色

    在ASP.NET中的gridview控件里面可以通过设定其OnRowDataBound事件来进行实现高亮当前行的操作 前端控件的设置: 只要设置好OnRowDataBound属性即可,会自动在.cs文 ...

  4. C# GridControl 行背景颜色

    使用C# DevExpress_gridControl 行号行样式显示行背景颜色,必须取消自动变换行色属性 取消Focus变色,属性为OptionSelection--EnableAppearance ...

  5. Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())

    在Qt中设置widget背景颜色或者图片方法很多种:重写paintEvent() , 调色板QPalette , 样式表setStyleSheet等等. 但是各种方法都有其注意事项,如果不注意则很容易 ...

  6. div 背景色设置_DIV背景颜色设置

    DIV 背景色设置篇-div背景颜色设置篇 一.div标签内直接设置背景颜色   -   TOP <div style="background:#000; color:#FFF&quo ...

  7. 【C#/WPF】Button按钮动态设置Background背景颜色

    学习笔记: 在XAML中给Button设置颜色大家都懂的,本篇只是记录用C#代码动态生成的按钮设置Background背景颜色. new一个Button,设置Background时可看到该属性类型是S ...

  8. 设置vim默认参数 例如设置默认背景颜色

    因个人喜好问题,本人使用vim的时候喜欢将背景颜色设为dark. 但是每次打开一个vim的时候都要重新设置一次,感觉非常麻烦. 总要输入[Esc] :set bg=dark很不方便 粗暴的办法是直接进 ...

  9. Silverlight DataGrid数据行背景颜色控制

    sdk:DataGrid数据绑定后,部分特殊的行需要用不同的背景颜色来显示.(注册DataGrid的LoadingRow事件) private void radGridView_LoadingRow( ...

随机推荐

  1. 优化JDBC编程-多提提意见

    优化JDBC编程这是我根据MS SQL SERVER 2000 JDBC DRIVER HELP,并参考其它资料整理而成.ms的这个帮助文件实在有失大家风范,示例代码很.....有兴趣者可以去下载ht ...

  2. Android之等比例显示图片

    在android中,由于密度的影响,如果想得到图片的宽高是不行的,具体为什么我就大概说一下,具体的请搜索度娘或者古哥吧. 原因是如果你把图片放在drawable-mdpi里,而手机是属于drawabl ...

  3. Object类型转换为long或者Long

    1.转换为long Object o = new Object();long l = Long.valueOf(String.valueOf(o)).longValue(); 2.转换为Long Ob ...

  4. TreeMap源代码深入剖析

    第1部分 TreeMap介绍 A Red-Black tree based NavigableMap implementation. The map is sorted according to th ...

  5. Apache PHP Mysql 开发环境快速配置

    学习PHP开发要配置各种环境,一般会用到apache作为服务器.Mysql数据库.如何快速的配置环境成为困扰大家的烦恼,之前自己也配过,比较繁琐. 最新发现一款集成安装软件“phpStudy”.真可谓 ...

  6. UVA 400 (13.08.05)

     Unix ls  The computer company you work for is introducing a brand new computer line and is developi ...

  7. 浅议 android下的context

    android学习中,最开始学习的一个类是activities,你是否知道他与context之间 的关系,我们经常用startactivities来唤起一个activities他的定义有在哪里了,他是 ...

  8. ftp 命令行操作 经常使用命令

    > ftp <host> [port] > pwd  # 查看当前文件夹 > dir  # 查看FTPserver中的文件及文件夹 > mkdir <dirn ...

  9. scala多线程

    object Test { def main(args: Array[String]) { //创建线程池 val threadPool:ExecutorService=Executors.newFi ...

  10. 强连通tarjan模版

    #include<stdio.h> #include<iostream> #include<math.h> #include<queue> #inclu ...