This topic is locked
[SOLVED]

Change row color not working

7/9/2022 8:00:42 PM
PHPRunner General questions
Davor Geci authorDevClub member

Hello,
I don't know what I'm doing wrong.

I want to change the row color in List Page After record proccessed but it doesn't work.

Here is the code that I'm using:

function BeforeMoveNextList($data, $row, $record, $recordId, $pageObject)
{

$deleted = 0;
$rs = DB::Query("SELECT * FROM punches WHERE id=".$recordId);
$rec = $rs->fetchAssoc();

$deleted = $rec["deleted"];

if ($deleted == 1){
$record["css"]='background:red;';
}

} // function BeforeMoveNextList

What I'm doing wrong?

Davor Geci authorDevClub member 7/9/2022

I have added some logging and it seems that this event is not triggered.

console.log('event is triggered');

$rs = DB::Query("SELECT * FROM punches WHERE id=".$recordId);
while( $rec = $rs->fetchAssoc() )
{
$deleted = $rec["deleted"];
console.log(' in deleted loop');
if ($rec["deleted"] == 1){
console.log('background color line');
$record["css"]='background:red;';
}
}

In Javascript Onload event I can see the message in console. But this List Page After record proccessed is not triggered at all.
Doesn't this event get triggered with page refresh?

Davor Geci authorDevClub member 7/9/2022

Uh, oh, I have mixed Javascript & PHP.
What a mess.
I'm new to PHPRunner.

But here is the answer to my own question:

if ($data["deleted"] == 1){
$record["css"]='background:red;';
}
fhumanes 7/10/2022

Hello,

I think you have several concept errors and therefore, errors in programming:

  • To access record data you don't have to make a new query again. You have all the fields of the recovered registration in the variable "$data".
  • The content of the "$recordId"" field is a reference to the contracted page, not the "Row" recovered.
  • All codification of this event is PHP, therefore it is executed on the server. Mix information or PHP code and JavaScript.

Cheers,
fernando

fhumanes 7/10/2022

Sorry, I hadn't read the last message