dhtmlxConnector and bold colum

Hi,

I saw a sample code where in php connector it is possible to load data with some color changes.



i would like to load values from a render_sql and make values in bold font in a particular colum…



load data is ok…and how can i show values in bold ?





Thank u

You can use “beforeRender” event to add “style” or “class” attribute to the necessary cell. Please find more information here dhtmlx.com/dhxdocs/doku.php?id=d … re_loading

Tried with sample color_rows with no luck…

could be a problem having render_sql instead of render_table?


The both methods are processed in the same way, so usage of render_sql must not cause any problems.
Be sure that
- custom event is attached before render_sql command
- you are using the same column name during custom coloring, as was used in sql query

Probably i’m not doing the right stuff…here’s my code:

require("…/dhtmlxSuite/dhtmlxConnector/php/codebase/grid_connector.php");

    function color_rows($row){
        if ($row->get_index()%2)
                $row->set_row_color(“red”);
    }


    $res=mysql_connect(“localhost”,“root”,“sandbgroup”);
    mysql_select_db(“hr_mysql”);

    $employee_grid = new GridConnector($res);
    $employee_grid->set_encoding(“ISO-8859-1”);
    $employee_grid->enable_log(“Log/employee_grid_connector.log”,true);
    $employee_grid->dynamic_loading(100);
   
   
   
 
   
    $employee_grid->event->attach(“beforeRender”,color_rows);
   
   
   
    $employee_grid->render_sql ("SELECT  hs.loc_code, hs.loc_city, b.employee_id, b.emp_lastname, b.emp_firstname, a.emp_number " .
        "FROM hs_hr_location hs " .
        "JOIN (hs_hr_emp_locations a " .
        "JOIN hs_hr_employee  b " .
        "ON (a.emp_number=b.emp_number)) " .
        "ON (a.loc_code=hs.loc_code) " .
        “WHERE b.emp_status<>‘EST011’ AND b.emp_status<>‘EST012’” .
        “AND (b.terminated_date LIKE” . “’” . date(“Y-m”) . “%” . “’”  .
        "OR b.terminated_date LIKE ‘0000-00%’) " .
        “”,“emp_number”,“employee_id,emp_lastname,emp_firstname,loc_city”);


is this the incorrect row?
if ($row->get_index()%2)   and how can i change it in order to make in bold the 1st colum?

              

The code which you are using is correct. The same php code works correctly in local samples. ( you can check the generated xml, it will contain bgColor attribute for necessary rows )
Problem can be caused by client side initialization. If you are using the skin with predefined color of rows ( some skin has default alter-css settings ) , the server side color setting can be overridden.
Please try to change the code of your custom method as


function color_rows($row){
if ($row->get_index()%2)
$row->set_row_style(“background-color:red;”);
}

style setting has a higher priority, and must not be overridden by client side settings.

Now it works and i’ve changed function into:

function bold_matricola($row)
    {
           if ($row->get_index()==0)
            $row->set_row_style(“font-weight:bold;”);
    }
  
obiviously it changes only the first row in bold…which is the correct function instead of ger_index() in order to change in bold a particular columm?

so:
function bold_matricola($row)

    {

           if ($row->columm==colum number 1)

            $row->set_row_style(“font-weight:bold;”);

    }

thank u

function bold_matricola($row)
{
$row->set_cell_style(“field_name”,“font-weight:bold;”);
}

where field_name is name of the column ( “emp_lastname” for example )

It works good now…thank u very much…may i ask another question?

if i would extend this function in order to find a particular value in a colum and then make this field in bold?

if ( in ex: emp_lastname == “Entrata”)
then set this row in bold?


function bold_matricola($row)
{
if ($row->get_value(“emp_lastname”) == “Entrata” )
$row->set_row_style(“font-weight:bold;”);
}

You can check full list of methods at
dhtmlx.com/dhxdocs/doku.php? … m_specific

Thank u again…
i’ll read the article