This topic is locked
[SOLVED]

 decimal places = 2 at TOTAL for col

4/15/2011 3:37:19 PM
PHPRunner General questions
N
nti author

phpr 5.3 build 7474
I have a decimal field in my db, type = decimal(9,2)
If I setup Editor: View as: Number = 2
Field shows up ok with 2 decimal places. I also require font to be red if > .01.
So I do custom Editor: View as: Custom



if ($value>0)
$color="red";
else
$color="black";
$value="<font color='$color'>$value</font>";


Now my decimal places no longer show up. Number is 1 instead of 1.00.
I tried:



if ($value>0)
$color="red";
else
$color="black";
$value="<font color='$color'>$value</font>";
number_format($value,2);


It does work ok, however the TOTAL for total of col is not showing decimal places. what is solution? for grand total col at bottom of col for two decimals?
If I choose View As: Number with 2 decimals: TOTAL for col is proper, however color font format does not work.
thank you for all answers.

N
nti author 4/15/2011

The solution I found and hopefully is correct coding.
I removed the custom code from View As Custom in editor.
I have selected View As Currency and Edit: Validate as Currency: Default "0.00"
I have placed in EVENTS: List Page: After record processed:



// ---------------------------------------------------------------------

//Below code modifies font color in specific row based on condition.
if ($data["My_Field_Name"]>.01){
$record["My_Field_Name_style"]='style="color:#ff0000"';
} if ($data["My_Other_Field_Name"]>.01){
$record["My_Other_Field_Name_style"]='style="color:blue"';

}
// ---------------------------------------------------------------------


The above works for changing font color for specfic field.
Now I am looking for way to modify font colors and/or background colors for row based on field value.
Any assistance feedback appreciated. nti