课程表

jEasyUI 应用

jEasyUI 拖放

jEasyUI 菜单与按钮

jEasyUI 布局

jEasyUI 数据网格

jEasyUI 窗口

jEasyUI 树形菜单

jEasyUI 表单

jEasyUI 参考手册

工具箱
速查手册

jEasyUI 条件设置行背景色

当前位置:免费教程 » JS/JS库/框架 » jQuery EasyUI

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

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

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

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

下载 jQuery EasyUI 实例

jeasyui-datagrid-datagrid18.zip

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号