How do I color a row based on the condition

Discuss everything related to ApPHP DataGrid class. All versions. Any questions related to the ApPHP DataGrid developing or using should be posted to this forum.
Please, check out Knowledge Base first before you post a question.

Moderators: ne_moj, zewa, vadimako, ne_moj, zewa, vadimako

Forum rules
Posts are to be made in the relevant forum. Users are asked to read the forum descriptions before posting.
wellsantos
Newbie
Newbie
Posts: 8
Joined: Dec 8th, '13, 16:25

How do I color a row based on the condition

Postby wellsantos » Dec 30th, '13, 22:49

How do I color a row based on the condition of some data in the database?
mode VIEW
ex:
id active product
----------------------
1 1 xxxxxxxx
2 0 xxxxxxxxx - this line in red ???
1 1 xxxxxxxxx
4 1 xxxxxxxxx


wellsantos
Newbie
Newbie
Posts: 8
Joined: Dec 8th, '13, 16:25

Re: How do I color a row based on the condition

Postby wellsantos » Jan 1st, '14, 18:25

$curr_value = str_replace(",", '', $fp_on_item_created($row[$c]));

this line not exist´s in my datagrid.php, my verion is lasted.

you already have the file ready where I can be testing or downloading?

administrator
Site Admin
Site Admin
Posts: 5959
Joined: Jan 7th, '09, 23:18
Contact:

Re: How do I color a row based on the condition

Postby administrator » Jan 5th, '14, 06:52

Try this one:
$curr_value = str_replace(',', '', $fp_on_item_created($row_c));

Does it exist?

cphil123
Junior
Junior
Posts: 22
Joined: Mar 28th, '11, 11:23
Location: Belgique

Re: How do I color a row based on the condition

Postby cphil123 » Jan 14th, '17, 23:10

Hi,

I would like to make sure to put the lines in color on the fly, when it is active or not active

I tested the following solution: http://www.apphp.net/forum/viewtopic.php?f=33&t=3295

I change the function:

Code: Select all

function SetColors($val, $r){
    $unique_prefix = "TACH_";
    if($val == "Oui"){
        echo '<script>document.getElementById("'.$unique_prefix.'row_"+'.$r.').style.backgroundColor = "#38c101";</script>';
    }elseif($val == "Non"){
       echo '<script>document.getElementById("'.$unique_prefix.'row_"+'.$r.').style.backgroundColor = "#ff0000";</script>';    
    }
    return $val;       
}

Could you provide a datagrid file as an example ?
all my tests fail ...

thank you for your support
Phil

cphil123
Junior
Junior
Posts: 22
Joined: Mar 28th, '11, 11:23
Location: Belgique

Re: How do I color a row based on the condition

Postby cphil123 » Jan 26th, '17, 20:33

hi,

is there a solution ? :roll:

Phil


Return to “ApPHP DataGrid”