Get KoolPHP UI with 30% OFF!

Is there anyway I can make a cell change its background color based on the value?

Igor
The following code will work but i dont know how to implement this code in koolgrid column,
somebody?
while($row = mysql_fetch_array($result)) 
  { 
  echo "<tr>"; 
  echo "<td>" . $row['value1'] . "</td>"; 
  echo "<td>" . $row['value2'] . "</td>"; 
  if($row['Quantity']>=32) 
         echo "<td style='background-color: #00FF00;'>".$row['Quantity']."</td>"; 
  else if($row['Quantity']<=15)/
         echo "<td style='background-color: #FF0000;'>".$row['Quantity']."</td>"; 
  else if($row['Quantity']>=16)
         echo "<td style='background-color: #FFFF00;'>".$row['Quantity']."</td>"; 
  echo "<td>" . $row['value4'] . "</td>"; 
  echo "</tr>"; 
  } 
echo "</table>"; 

Tnx
Igor
Posted Apr 3, 2016 , edited Apr 3, 2016 Kool
RICHARD PERRIS
class function_schedule_grid extends GridEventHandler
{

function OnRowPreRender($row,$args)
{

.....
while($row = mysql_fetch_array($result))
{

if($row['Quantity']>=32)
$row->CssClass="css_class1";
else if($row['Quantity']<=15)/
$row->CssClass="css_class2";
else if($row['Quantity']>=16)
$row->CssClass="css_class3";
$row->CssClass="css_class4";
}


}



}
$main_grid->EventHandler = new function_schedule_grid();
$main_grid->Process();
You need your css in the site css folder.
Hope it helps
Posted Apr 8, 2016 , edited Apr 8, 2016 Kool -
Igor
Warning: Attempt to assign property of non-object in /home/..../public_html/2/nxxxa.php on line 226
	class farbanje extends GridEventHandler
		{
		function OnRowPreRender($row,$args)
	{
	$result = mysql_query('SELECT TIMESTAMPDIFF(day, CURDATE(), rezerviran_do) AS alarm_rezervacija 
	FROM bitno
	');
    while($row=mysql_fetch_assoc($result))
	{
		if($row["alarm_rezervacija"]<=25)    // if($row->DataItem["alarm_rezervacija"]<=25)
                             $row->CssClass="defaultzeleno";      //*** line 226 ***
		else if($row["alarm_rezervacija"]>=26)
		             $row->CssClass="defaultcrveno";
		//else if($row["id"]>=16)
			   //$row->CssClass="defaultzuto";
		}}}
		
           // $column = new GridBoundColumn();
	// $validator = new CustomValidator();
	// $validator->ValidateFunction = "farbanje";
	// $column->AddValidator($validator);
	// $grid->MasterTable->AddColumn($column);	
	$grid->EventHandler = new farbanje();
...in css file //KoolPHPSuite/KoolControls/KoolGrid/styles/default/default.css
.defaultcrveno
{
	background-color:#E6A9EC;
}
.defaultzuto
{
	background-color:#E5E4E2;
}
.defaultzeleno
{
	background-color:#00FF00;
}
Posted Apr 8, 2016 , edited Apr 9, 2016 Kool
Paul
Is there anyway to refer to the fieldname variable? This did not work for me.
class MyGridEventHandler extends GridEventHandler
	{
		function OnRowPreRender($row,$args)
		{
			//$row: The grid row object.
			//$args: No data
			if ({mydataenabled} == 1) {
				$row->CssClass = "redColor"; // Make the row in red color.
			}
		}
	}
$grid->EventHandler = new MyGridEventHandler();

Nevermind, I figured it out
$row->DataItem['mydataenabled'] == 1
Posted May 26, 2016 , edited May 26, 2016 Kool
Igor
BIG THANX Paul!!!
Posted Jun 22, 2016 Kool