This topic is locked

Conditional formatting

5/4/2007 11:05:11 AM
PHPRunner General questions
M
mrpeeble author

I want to color a row red when certain field conditions are met, such as when ChequeProduced=No.
If this is possible please advise.

Admin 5/7/2007

Coloring the whole row is not possible without code modification.
To change background color of any table cell use "View as" type "Custom".

J
jskewes 5/23/2007

ADMIN - I have the same or similar question.

As an example; If the field value is; DONE I would like the field to be green. If the value were; NOT STARTED, I would want the field to be red.

How would this be accomplished? I have looked through the help files and do not find much guidance. Not being a programmer I am at a loss.

Also - this would be a great feature in a future release - a conditional formatting dialog.

Thanks,

/john

J
Jane 5/23/2007

John,
to highlight field value proceed to the Visual Editor tab, double click on the field, select Custom on the "View as" settings dialog and add your code in it.

Here is a sample:

$str = "<table width=100% bgcolor=";

if ($value="DONE")

$str.="green";

if ($value="NOT STARTED")

$str.="red";

str.="><tr><td>".$value."</td></tr></table>";

$value=$str;

J
jskewes 5/25/2007

Hi Jane,

Thanks for your help.

I when I insert the code below I get this error;

Parse error: syntax error, unexpected T_CONCAT_EQUAL
any ideas on that?

Thanks,

/john

John,

to highlight field value proceed to the Visual Editor tab, double click on the field, select Custom on the "View as" settings dialog and add your code in it.

Here is a sample:

Admin 5/25/2007

Try this:

$str = "<table width=100% bgcolor=";

if ($value=="DONE")

$str.="green";

if ($value=="NOT STARTED")

$str.="red";

str.="><tr><td>".$value."</td></tr></table>";

$value=$str;
K
kjp 6/29/2007

Bonjour
Is it possible to apply that on a cell looking condition value IN an another one?
cell("A"column):

if cell("C"column) value = "somevalue"

then color="somecolor"
and in the same way,

how to change the police's color of the cell (instead of the background)?
Thanks

J
Jane 6/29/2007

Hi,
to select value from another column use this code:

global $data;

$str = "<table width=100% bgcolor=";

if ($data["C_column"]=="DONE")

$str.="green";

if ($data["C_column"]=="NOT STARTED")

$str.="red";

str.="><tr><td>".$value."</td></tr></table>";

$value=$str;



where C_column is your actual field name.
I'm not sure what does police's color means. Please explain.

K
kjp 6/29/2007

Thanks

just it!
sorry for my poor English

For the "police":

How to do the same thing but with the text color instead of background

J
Jane 6/29/2007

Try to use this code:

global $data;

$str = "<font color=";

if ($data["C_column"]=="DONE")

$str.="green";

if ($data["C_column"]=="NOT STARTED")

$str.="red";

str.=">".$value."</font>";

$value=$str;

O
osluk 11/7/2007

Jane I think the $ was missing from this one as well
Replace str.=">".$value."</font>"; with $str.=">".$value."</font>";
PHP is not very forgiving!
Cheers Chris

Try to use this code:


M
mmponline 2/13/2008

I'm trying to use this code to change background in costom code on view page. Get error message:
Parse error: parse error, unexpected T_CONCAT_EQUAL in /usr/www/users/mmpo/projects/include/commonfunctions.php on line 380

$str = "<table width=100% bgcolor=";

if ($value=="Ella")

$str.="green";

if ($value=="Maryna")

$str.="red";

str.="><tr><td>".$value."</td></tr></table>";

$value=$str;


Is the code different for 4.2 (Build 340)

J
Jane 2/13/2008

Stephan,
this code looks correct.
Please publish your project on Demo Account and post a URL to your pages here or send it to [email=support@xlinesoft.com]support@xlinesoft.com[/email] along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

V
vytb 2/13/2008

I want to color a row red when certain field conditions are met, such as when ChequeProduced=No.

If this is possible please advise.



It works with me when I change str to $str.
However, if I use 'readonly' option, the code is seen, instead of the value. Is there a workaround?

J
Jane 2/13/2008

Vitas,
yes you're right with $str.
Regarding the second question.

I'm not sure that I understand you correctly. Custom code is on the "View as" settings dialog but Readonly option is on the "Edit as" settings dialog.

V
vytb 2/13/2008

Vitas,

yes you're right with $str.
Regarding the second question.

I'm not sure that I understand you correctly. Custom code is on the "View as" settings dialog but Readonly option is on the "Edit as" settings dialog.


You are right. I'm trying to use the code for the field which shouldn't be editable. Thus, can both options (View as and edit as) be used? If so, how to avoid displaying the code on read only field?
Thanks Jane.

M
mmponline 2/13/2008

Working perfect with the $str.
Thanks again for your support. This forum is great!!!1

M
mmponline 2/13/2008

The code shows fine in list page. For some reason on the master /detail relation it does the following on the Master Table Info (List) page created.
Instead of the colour background, it shows the following in the field's cell
<table width=100% bgcolor=#FFCCCC><tr><td>Marthina</td></tr></table>

O
olegsg 2/13/2008

I have similar (HTML) problem but with font color.
In Custom area I have entered following code for font conditional formatting

(Added 2 colors, Red and Blue (#3300FF)):
global $data;

$str = "<font color=";

if ($data["Fld"]=="0" and

$data["Status"]=="Awaiting")

$str.="#3300FF";

if ($data["Fld"]=="0" and

$data["Status"]=="Positive")

$str.="Red";

$str.=">".$value."</font>";

$value=$str;
It works fine in List page, but View page looks like this:
CntNr <font color=#3300FF>1</font>

NegTime

Company <font color=#3300FF>Janssen</font>

Pos <font color=#3300FF>CTA</font>

City [color=#0000FF]M

Candidate <font color=#3300FF>Larkina Anastasia</font>

NegType <font color=#3300FF>Signing</font>

Fld

Status <font color=#3300FF>Awaiting</font>

IntViewer <font color=#3300FF>Anna</font>

Winner [color=#0000FF]Pending
Some View pages are generated without any HTML garbage, others - like above.

V
vytb 2/14/2008

As I wrote, I had this problem when I used 'readonly' option. Otherwise, is OK. Is it your case?

O
olegsg 2/14/2008

As I wrote, I had this problem when I used 'readonly' option. Otherwise, is OK. Is it your case?


Mainly I used Text field and Lookup wizard and never Readonly.

M
mmponline 2/14/2008

In my case the list page is fine, but the master page of the master /details page is "haywire"

M
mmponline 2/14/2008

I see this problem is gone in the Beta version that came out today. Yippeee!

P
pm8317 3/3/2008

John,

to highlight field value proceed to the Visual Editor tab, double click on the field, select Custom on the "View as" settings dialog and add your code in it.

Here is a sample:


Is there any way to pass these Custom settings to the Master Table Info (list) page? The code is there in visual editor/ Master Table Info (list) but it doesn't work. The List page works fine.
Thanks

Patrick Marshall

J
Jane 3/3/2008

Patrick,
it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

P
pm8317 3/5/2008

Patrick,

it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.


It works fine if I use code like this:
global $data;

$str = "<font color=";

if ($value=="DONE")

$str.="green";

if ($value=="NOT STARTED")

$str.="red";

$str.=">".$value."</font>";

$value=$str;
However If I use a value from a different column it only will work in the main list not the Master Table Info:
global $data;

$str = "<font color=";

if ($data["C_column"]=="DONE")

$str.="green";

if ($data["C_column"]=="NOT STARTED")

$str.="red";

$str.=">".$value."</font>";

$value=$str;
Thanks

Patrick Marshall