基于条件的Jquery Bootgrid表行颜色 [英] Jquery Bootgrid table row color based on condition

查看:617
本文介绍了基于条件的Jquery Bootgrid表行颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据我的条件更改行颜色。
我使用Bootgrid js( http://www.jquery-bootgrid.com/Documentation

i would like to change row color based on my condition. I am using Bootgrid js (http://www.jquery-bootgrid.com/Documentation)

以下是示例:


  • 我的条件可以是1或0

  • 如果是1则需要红色背景颜色,如果为0 - 默认

这适用于正常表格

<?php 
if(condition = 1){
  <tr class="red">
} else {
  <tr>
}
?>

我尝试过
模板格式化程序,但它适用于整个表格而不是我的条件

I have tried with template formater but it apply on whole table not on my condition

有人知道这是可能的,如何做到这一点?
Thx

Does anybody know is this possible and how to do this? Thx

推荐答案

您可以使用2种方法

1)如果下面的语句短路

1) shorted if statement like below

<tr <?PHP echo ($condition == 1 ? 'class="red"' : ''); ?>>

2)正常if语句

<?php 
   if(condition == 1){
     <tr class="red">
   } else {
     <tr>
   }
?>

另一种方式

$a_json_row["status"] = 0; // success row
$a_json_row["status"] = 1; // info row
$a_json_row["status"] = 2; // warning row
$a_json_row["status"] = 3; // error row

下面的js代码扩展状态映射。

the below js code extend the status mappings.

$("#grid").bootgrid({
    statusMappings: {
        4: "wrong"
    }
});

这篇关于基于条件的Jquery Bootgrid表行颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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