Change Cell-color depending on his text

Hello

I need to set a different color if the value is higher than 50. I did like the documentation said but the color doesn’t change :frowning:

<?php $wonr = $_GET['wonr']; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
   <head>
      <link href="../dhtmlx/Connector/dhtmlx.css" rel="stylesheet" type="text/css" charset="utf-8">
      <link href="../dhtmlx/Grid/codebase/skins/dhtmlxgrid_dhx_skyblue.css" rel="stylesheet" type="text/css">
      
      <script src="../dhtmlx/Grid/codebase/dhtmlxcommon.js"></script>
      <script src="../dhtmlx/Grid/codebase/dhtmlxgrid.js"></script>        
      <script src="../dhtmlx/Grid/codebase/dhtmlxgridcell.js"></script>      
      <script src="../dhtmlx/Connector/dhtmlx.js" type="text/javascript" charset="utf-8"></script>
      <script src="../dhtmlx/Connector/dhtmlxdataprocessor.js" type="text/javascript" charset="utf-8"></script>
      <script src="../dhtmlx/Connector/connector.js" type="text/javascript" charset="utf-8"></script>
   </head>

   <body>
      <div id="gridbox" width="338px" height="103px" style="background-color:white;overflow:hidden"></div>

      <script>
	     myGrid = new dhtmlXGridObject('gridbox');
	     myGrid.setImagePath("../../dhtmlx/Grid/codebase/imgs/");
	     myGrid.setHeader("Name, Strasse, TX, RX, SN");
	     myGrid.setInitWidths("70,*,40,40,40")
	     myGrid.setColTypes("ro,ro,ro,ro,ro");
	     myGrid.setColSorting("connector,connector,connector,connector,connector");		 
	     myGrid.setSkin('dhx_skyblue');
	     myGrid.attachEvent("onXLE", function(){
			 rows = myGrid.getRowsNum();
			 for (var i = rows -1; i >= 0; i--) {
				 txt = myGrid.cells2(i, 2).getValue().toString().toLowerCase();
				 if(txt >= 50) { myGrid.setRowColor(i, "F46899"); }
			 };
        });
		  myGrid.init();
	     myGrid.loadXML("../../php/connector.php?wonr=<?php echo $wonr; ?>");
      </script>
   </body>
</html>

Is there a way to change just the specified column? Where’s my mistake?

Thank you in advance.

Best regards
Oli

setRowColor() method uses row_id but not the row_index.
Please, try to modify your code the following way:

    if(txt >= 50) { myGrid.setRowColor(myGrid.getRowId(i), "F46899"); }

Thank you … as i just need to change the font color i tried:

if(txt >= 50) { myGrid.setRowTextStyle(myGrid.getRowId(i), "color:red"); }

It works well but how can i use this code for a specified column?
For example: I want that only column 3 gets the new color.

Thank you :slight_smile:

Found

if(txt >= 50) { myGrid.setCellTextStyle(myGrid.getRowId(i), 2, "color:red"); }

and works really well :slight_smile:

Thank you