Update from grid datetime field in MSSQL table

i have php file where connection is configured. There is code

$grid->render_sql("select IdDir, Dir_name, convert(varchar, date_time, 120) as moddate from Dir","IdDir","IdDir, Dir_name, moddate"

Grid declared in html

mygrid = new dhtmlXGridObject('gridbox');
	mygrid.setHeader("IdDir, Dir_name, Datetime");
	mygrid.setInitWidths("100,100, *")
	mygrid.setColTypes("ro,ed,dhxCalendarA");
	mygrid.setColSorting("int,str,date");
	mygrid.init();
	mygrid.loadXML("mssql_connect.php");

And i try to update “Datetime” field but don’t have any change in database. Help me to resolve this problem. Thanks.

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.

You can use beforeRender handler

docs.dhtmlx.com/doku.php?id=dhtm … formatting
docs.dhtmlx.com/doku.php?id=dhtm … nder_event

All resolved. Many thanks.

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?

Which type of column you are using on client side for date showing.
If it is a dhxCalendar you may need to use

grid.setDateFormat

to specify which date format need to be used on client side.

i use ‘date’ type.

i’m sorry of course ‘date’ type for sorting but column is ‘ed’ type.

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.

i use pasteBlockFromClipboard() my processing of ‘beforeUpdate’ event is called but when i use >>addRowFromClipboard() didn’t?

There are separate events for each type of CRUD operations

beforeInsert
beforeUpdate
beforeDelete

beforeProcessing is called for all types of CRUD operations

docs.dhtmlx.com/doku.php?id=dhtm … _execution

Thanks for your help.