Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by APres on Apr 25, 2009 02:51
open dhtmlx forum
beforeRender

In the manual of Connector I read

5. Formatting/Changing Data before Loading
In case you need to update values which were returned from database table or set some specific formatting before sending them to client side, you should use the "beforeRender" event handler. For more details see Events System chapter of this manual.


But I can't find anywhere anything more about the beforeRender event handler.

Actually I need to implemetent the filter for the date field.
Mysql format is "Y-m-d" while I show and would search in "d-m-Y"

How can it be done. Of course the implementation of calendar into filter should be the even better.
Answer posted by Support on Apr 25, 2009 05:28
>>But I can't find anywhere anything more about the beforeRender event handler.
You can check 
http://dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=8912&ssr=yes&s=beforeRender
Also, package contains
   samples/grid/02_rendering_connector.php
which can be used as sample of usage

To have custom dates in grid you may have 

function formatting($row){
     //formatting date field
    $data = $row->get_value("other_field");
    $row->set_value("other_field",date("d-m-Y",strtotime($data)));
}
 $grid->event->attach("beforeRender","formatting");


To have change filtering, you can use 

function custom_filter($name,$value){
   if ($name == "other_field") 
         return " other_field > ".some_date_formatting_code($value);
}
 $grid->event->attach("beforeFilter","custom_filter");

Where other_field - name of db field, which stores data