If i change in php file render_sql on render_table then in browser i have in datetime field value in “Apr 16 2011 12:00AM” format. Where can i change format of datetime field in grid? I want to use “dd.mm.yyyy hh:mm:ss” or any other.
Stanislav, now i have new problem. When i update datefield in grid the updated value save in the mssql with some time shift. For example:
when i insert 01.01.2000 12:00:00 in the mssql table i receive 01.01.2000 12:01:00
when i insert 01.01.2000 15:00:00 in the mssql table i receive 01.01.2000 03:01:00
when i insert 28.05.2010 17:46:00 in the mssql table i receive 28.05.2010 05:05:00
when i insert 28.05.2010 19:26:00 in the mssql table i receive 28.05.2010 07:05:00
I used beforeRender event where attached function
function formatting($row){
$data = $row->get_value("date_time");
$row->set_value("date_time",date("d.m.Y h:m:s",strtotime($data)));
}
and beforeUpdate event where attached function
function formatting2($row){
$data = $row->get_value('date_time');
$data = date("Y-m-d h:m:s", strtotime($data));
$row->set_value("date_time",$data);
}
How to resolve this?
I find out some peculiarity.
When i insert into grid new values into datetime field from clipboard by paste - all ok.
But when i try to insert new row into grid values in datetime field are converting to another format (day and mounth change places) and i don’t know why. I suppose that solution may be found by digging in setUserData method (dhtmlxgrid.js) where the 3rd argument is ‘existing’ when i use pasteBlockFromClipboard() and ‘inserted’ when i use addRowFromClipboard(). Or is did another event call before my ‘beforeUpdate’ function is called?
If you are using ed column - data from it will be sent to server side without any modifications, where it will be inserted in sql query.
The problem can occur if you are using date format which is different from one expected by mysql, otherwise it all must work correctly.
If necessary you can assign code to beforeProcessing event and do any kind of transformation with data from client side, before it will be used in sql query.
Stanislav, thank you for help. But processing of 'beforeProcessing ’ event is very slow. Can you explain me why when i use pasteBlockFromClipboard() my processing of ‘beforeUpdate’ event is called but when i use addRowFromClipboard() didn’t?
i have resolved this problem by including ‘beforeUpdate’ and ‘BeforeInsert’ event processings. Most likely it is not call ‘beforeUpdate’ event when i insert new rows.