Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Daniel Alonso on Feb 25, 2009 10:04
open dhtmlx forum
Dinamic class on datagrid

I`m loading a dynamic datagrid from a mysql database via php. I having no problems formating the XML and everything is working fine.
I have a boolean field on the database ( can only be 0 or 1) and i want to change the grid backgroung for the row depending on the value of this field.
I tried to add a CDATA for the row but doesnt work, then i tried to add a CDATA for the cells and it only write me the html on the cell
I`m doing something like that

/* CODE */

$class = " ";
if($row['field'] == 1)
{
$class = "<![CDATA[ style='background-color:#FF0000']]>";
}
$string_to_print = "
<?xml version="1.0" encoding="iso-8859-1"?>
<rows>
        <row id='1'>
            <cell>field 1".$class."</cell>
            <cell>field 2".$class."</cell>
        </row>
    </rows>
";

I using the tabs for clearing code, in my code the xml is just one line

Thats is not working, i get style='background-color:#FF0000' writed on the cell when the cell is empty and nothing when the cell have any data
There are any way to fo what i want to do?
Thanks in advance
Answer posted by Support on Feb 25, 2009 10:23
If you need to set style for whole row you can use attribute of the row tag.


<?xml version="1.0" encoding="iso-8859-1"?> 
<rows> 
  <row id='1' ".$class." >

value of style attribute of row tag will be applied to all cells in row. ( also there is bgColor attribute, which can be used for row color setting )
Answer posted by Daniel Alonso on Feb 25, 2009 10:37
Thanks
i use the bgColor and it works fine