Processing of errors in query

I want to create next.
I have grid and I load to it datas from the server by sending request in url. I must clear current datagrid to load new datas but if query is wrong grid will be empty. How do to process errors? How can i receive at first error events from the server without reading log files? Thanks.

You can use code like next to catch data loading errors

dhtmlxError.catchError("LoadXML", function(type, name, params){ //params[0].responseText - exact text of server side response });

It’s not working :frowning: I build condition and insert it into query. But when my condition is wrong, my grid is empty but has no error messages.
I I want to catch errors like “Query failed” or something else.

If you are using connector for the server side operations - it saves errors in log instead of direct output to the client side. ( in case of CRUD operations - response with error type processed, which can be handled through dataprocessor’s API )

If you are using custom code - what is the response in the problematic case? Above code will catch error only if response is not a valid XML document

I use dhtmlxconnector. How i can catch info from log?

You can enable saving log to file by using


but it will not change the data which is returned to client side. It will be a valid data for the correct operation or empty response for the error.

As alternative solution you can use code like next

dhtlmxAjax.get(url, function(loader){ // here - loader.xmlDoc.responseText - text of server side response var text = loader.xmlDoc.responseText; if (some_custom_check(text)) grid.parse(text); else show_error_message(); }

Thanks for answer, but i insert into function query of MsSQLDBDataWrapper class msg

if(!$res){ $error_msg = mssql_get_last_message(); die('MSSQL error: ' . $error_msg); }
it is enough for me.

Stanislav, can you help me again?
Now i want to realize next:
user insert new rows into grid; then he synchronize grid with database’s table; rows, that wasn’t inserted into database’s table, must stored in somewhere (or may be their rowids return to user or some information about this rows).
Can you provide me some example of code to realize this? In the documentation i find some info about Server Side Responses But without some example it is difficult to understand this process. Thanks.

Are you using dataprocessor or custom logic?

The article which you have mentioned is related to the dataprocessor | connector logic. By default this is a simple xml tag with operation name and id of record. It possible to add extra attributes or custom response types and retrieve such info on client side ( so server can provide extra data back to client after data saving in DB )

on server side

<data> <action type="some" sid="r2" tid="r2" sync="not saved" /> <action type="some" sid="r3" tid="r3" sync="correct" /> <data>
on client side

dp.attachEvent("onAterUpdate", function(a,b,c,tag){ if (tag.getAttribute("sync") == "not saved") do_some(); return true; })

If you are using custom data saving - the above article is not actual.

Stanislav, thanks for reply.
I use dataprocessor.
Can you explain what are mean parameters “a,b,c” in code

dp.attachEvent("onAterUpdate", function(a,b,c,tag) … erupdate&s[]=onafterupdate

Those will be

dp.attachEvent(“onAterUpdate”, function(sid, action, tid, tag)

basically action type and record id

Many thanks. I think this is enough for me.

I try to insert rows with invalid data and then sync grid with datatable, but i receive only “MSSQL error: Error converting data type varchar to numeric” and processing don’t call “onAterUpdate” event. When is executed data converting and how catch errors from this processing and take info about invalid rows? Thanks.

I found that sync with db don’t call any “onAterUpdate” event. Why is it?
This is my code. I call sync() or deleteRows() and my grid was refreshed but event didn’t call.

[code] dp = new dataProcessor(“file.php”);
dp.setTransactionMode(“POST”, true);

dp.attachEvent("onAterUpdate", function(sid, action, tid, tag){
	try {
			var str = "";
			for(var key in tag) {
			str = str +"key : "+ key +", value : "+ tag[key]+"\n\r";
	catch (e){
	return true;

function create_grid(){
	if ((value_plan*1) == 0) {
		row_count.value = 0; return;
	if (sql_query.value.toString() == ""){
		row_count.value = 0; return;
	data_url = "";
	data_url = sql_query.value;
	data_url = encodeURI(data_url);
	dp.serverProcessor = data_url;
	dhtmlxAjax.get(data_url,function (loader){
			row_count.value = loader.xmlDoc.responseXML.getElementsByTagName("rows")[0].getAttribute("total_count");
		catch(e){ alert (;}

function sync(){

function deleteRows(){

I found that sync with db don’t call any “onAterUpdate” event. Why is it?
Most probably - incorrect server side response.
Normally, it must be an xml with action tags, but if you have some kind of sql error - error output can break output xml , which prevent its correct parsing on client side and as result will break correct event processing.

You can try to use firebug|dev-tool and check the exact server side response for sendData command - is it valid xml, or contains a mixed output

But my table update when i insert correct data and “onAterUpdate” event didn’t call anyhow.

This is that i research in firebug
getresponseText “<?xml version='1.0' ?>”
getstatusText - OK
getstatus - 200

May be need else other parameters?

Strange, this line in xml must be enough to trigger the onAfterUpdate handler

Just to be sure - latest version of dataprocessor is attached - you can try to use it instead of the original one. (7.18 KB)

Stanislav, thanks for reply.
I changed dhtmlxdataprocessor.js with this new but not found any changes in call event. May it is dealed with encoding or some else?

Stanislav, all is ok. It is my fat fingers. I type “onAterUpdate” instead of “onAfterUpdate”. Now all is work correctly.