问题
i would like to change row color based on my condition. I am using Bootgrid js (http://www.jquery-bootgrid.com/Documentation)
Here is example:
- my condition can be 1 or 0
- if it´s 1 than I need red background color, if 0 - default
This works on "normal" tables
<?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
Does anybody know is this possible and how to do this? Thx
回答1:
You can use it with 2 methods
1) shorted if statement like below
<tr <?PHP echo ($condition == 1 ? 'class="red"' : ''); ?>>
2) Normal if statement
<?php
if(condition == 1){
<tr class="red">
} else {
<tr>
}
?>
Another way
$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
the below js code extend the status mappings.
$("#grid").bootgrid({
statusMappings: {
4: "wrong"
}
});
来源:https://stackoverflow.com/questions/38076463/jquery-bootgrid-table-row-color-based-on-condition