This topic is locked

Cell Background

3/10/2021 3:45:58 PM
PHPRunner General questions
kanclerz author

Hello. I am writing about the cell background that I want to change depending on the field value. I have a database in which I have the status field has the value INT, I put the value 1 YES, 2 NO, 3 NONE. I came across a tutorial https://www.youtube.com/watch?v=ch_cADcTnP4&t=302s in which it is described and it still does not work for me. I'm inserting the code

$record["status_style"].='style="background:red"';
if ($data["status"] == "NIE")

$record["status_style"].='style="background:blue"';
if ($data["status"] == "BRAK")

$record["status_style"].='style="background:green"';[/code]
in which it is described and it still does not work for me. I put the code from the level of custom "status" or like in the tutorial from the level of Events and nothing only works is the change of the font color depending on the status I am a PHPRunner user since version 9.8 a week ago I bought a license for 10.5 and the problem is the same. Has anyone encountered a similar problem, best regards.

HJB 3/10/2021

Screenshot ex mentioned video
As you can see, your code looks totally different to what the "Tips & Tricks" Youtuber

had been using and moreover, you use " instead of ' to bracket the wished color.
P.S. Drill down to "Changing the background of a cell" within https://xlinesoft.com/phprunner/docs/conditional_formatting.htm
and as you can see within the online manual of PHPRUNNER, the Youtuber is using the same coding as seen in the manual.

kanclerz author 3/12/2021

It does everything as in the Tutorial but still doesn't work. Below he publishes a gif showing step by step the steps to be taken Where I made a mistake
https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=94083&image=1&table=forumreplies?dl=0

A
acpan 3/13/2021

There is very obvious difference between your codes versus the manual's code:
Manual's Code adapted to yours:



// To change any cell background color, use the following code in the After Record Processed event.

if ($data["status"] == "NIE" ) {

$record["status_css"]='background:blue;';

}

else if ($data["status"] == "BRAK")

{

$record["status_css"]='background:green;';

}

else

{

$record["status_css"]='background:red;';

}


Your Code:



$record[“status_style”].=’style="background:red"‘;

if ($data["status"] == "NIE")

$record[“status_style"].=’style=”background:blue”‘;

if ($data["status"] == "BRAK")

$record[“status_style"].=’style="background:green"‘;


"xxxx_style" and "style=...." in your codes are wrong syntax and your single quote using [size="7"]’[/size] versus normal single quote [size="7"]'[/size] may also cause problem.

Also you tried to concatenate the styles that way is wrong.
Try to read the manual and cut and paste carefully and state your PHPRunner's version and where you put your codes (which events) in future so that people can help you with ease.
Also if it does not work, try reset your page (in case you had edited the page since ver 9.8).

kanclerz author 3/13/2021

I know, but please refer to the code it executes showing it on the animated gife. I use version 10.5 on a daily basis. I know that when pasting a piece of code on the forum, the symbols', "change, but as in the attached gif, I'm using the correct ones, as in the tutorial where everything works.

A
acpan 3/13/2021

It seems your field is not recognized due to the dash in your fieldname, which means CSS is not applied.
You better not use dash or Hyphen in your fieldnames, in fact table, fieldnames and database name should not contain dash. One way is to use alias if you have dash, eg. SELECT fieldname-with-dash as fieldname_without_dash FROM your_table
Read the reasons.
From above link: "Hyphens are a big problem because if you end up mapping a column name to a variable, most languages do not like to have hyphens inside variable names. Perhaps you are using one of the Java libraries that automatically generates variables or objects whose names are based on column names."