This topic is locked
[SOLVED]

 How to change colors for cells on grid and bootstrap

12/16/2016 8:21:32 AM
PHPRunner General questions
J
joshfolgado author

Hi,
Using bootstrap I need to color-code cells in the list views, according to values found.
Using layouts I have it working with the code below on the "List Page: after record processed".
$strTest="";

$strTest=$data["Archive_Status"];

$x="1";
if ($strTest == "Active") {

$record["Archive_Status_style"]=$record["Archive_Status_style"]."style='background:#33cc00 '"; // 'This is GREEN color

}

elseif ($strTest == "Not Being Used") {

$record["Archive_Status_style"]=$record["Archive_Status_style"]."style='background:#ff6600 '"; // 'This is ORANGE color

}

elseif ($strTest == "Banned") {

$record["Archive_Status_style"]=$record["Archive_Status_style"]."style='background:#322f30 '"; // 'This is a BLACK color

}

elseif ($strTest == "Deleted") {

$record["Archive_Status_style"]=$record["Archive_Status_style"]."style='background:#6b5858 '"; // 'This is a darker PURPLE color

}

else {

$record["Archive_Status_style"]=$record["Archive_Status_style"]."style='background:#569fb3 '"; // 'This is BLUE color

}
Been trying to find how to do the same with the bootstrap themes and didnt find any relevant information, exception being this next link that shares how do something similar after an inline edit/add, https://xlinesoft.com/phprunner/docs/how_to_control_inline_add_edit_functionality_from_script.htm.
Using the example in the link above I noticed that it mentions a new object "field", which I didnt see in the layouts, only now on the bootstrap themes. How can I get to this "field" in whatever view, i.e. add/edit/list?
Question:

How do I color code cells on screen using bootstrap? I need that when the page loads, it checks for values and colors individual row cells according to the values found.
PS. I attached an image that shares a working solution using the standard layouts.


Many thanks

Josh

J
joshfolgado author 12/16/2016

I found the solution for having the ability to color cells according to values.
$strAdStatus = "";

$strAdStatus = $data["Ad_Status"];
if ($strAdStatus == 'Active') {
$record["Ad_Status_css"]='background:#33cc00;'; // 'This is GREEN color

} else if ($strAdStatus == 'Draft') {

$record["Ad_Status_css"]='background:#ff6600;'; // This is ORANGE color

} else if ($strAdStatus == 'Removed') {

$record["Ad_Status_css"]='background:#993399;'; // 'This is GREEN color

} else if ($strAdStatus == 'Removed and Closed') {

$record["Ad_Status_css"]='background:#322f30;'; // This is a BLACK color

} else if ($strAdStatus == 'Closed') {

$record["Ad_Status_css"]='background:#322f30;'; // This is a BLACK color

} else if ($strAdStatus == 'Banned and Closed') {

$record["Ad_Status_css"]='background:#322f30;'; // This is a BLACK color

} else if ($strAdStatus == 'Banned') {

$record["Ad_Status_css"]='background:#ff1a1a;'; // This is a lighter RED color

} else {

$record["Ad_Status_css"]='background:#569fb3;'; // This is BLUE color

}
The syntax is different than when using layouts (example at the beginning of this topic), but the functionality is the same.
Hope this helps someone else, I spent many hours looking for any information on how to color item backgrounds using bootstrap, didnt find anything about it anywhere.
Thanks