Help with DataStore, Connector & DataProcessor


I am trying to use datastore & connector/dataprocessor together.

My includes are as such …

<script src="dhtmlx/dhtmlx.js"></script>
<script src="dhtmlxConnector/codebase/connector.js"></script>

DataProcessor/DataStore initialization is as follows:

	data = new dhtmlXDataStore();
	dp = new dataProcessor(url);

Somewhere further down my code, I am trying to insert a record into the datastore (and have it written to the database) as well as update the same record.

Insert Code:

dataObj = {
	id: "MyID"
	Field1: "1",
	Field2: "2",
	Field3: "3"

and Update code as:

dataObj = {
	id: "MyID"
	Field1: "4",
	Field2: "5",
	Field3: "6"

My problem is that in both the update and insert calls, data is sent as “INSERT”. So the first add call is successful, but the 2nd update call fails as MyID already exists in the database (coz it is inserting and not update the row).

How can I get it to update the row instead of inserting? While I am asking, how do I make it delete the same row as well?
Thanks for the help!

In second case, when you are calling data.update(dataObj); - are you sure that data with such ID already exists in datastore?

I’m not quite sure which code you are using on server side, but if those are default connectors, they will update id of record on client side with actual DB id, so after data saving id on client may differ from the one which you have specified in the add command ( if you are using id auto-generation on server side )

Second thing which need to be checked - response from server side for first insert operation - it must be valid xml with correct sid parameter. If response is wrong - client side code will may try to insert data with second call instead of updating.

Beware that data.update - updates data on server side, but it doesn’t mean that on server side it will result in update operation ( in most cases - yes, but if datastore thinks that data doesn’t exists in database it will generate insert operation )


I am literally calling data.update(dataObj) with the ID of “MyID” or a similar alphanumeric id. Thus, it’s confirmed to be the same.

For the server side, the code is …

	$conn = mysql_connect($mysql_server, $mysql_user, $mysql_pass);

	$data = new DataConnector($conn, "MySQL");
	$data->render_table("aTable", "Id", "Id, Field1, Field2, Field3");

and from the logs, I see …

Edit operation finished
0 => action:inserted; sid:1342078252239; tid:1;

after the first insert, and …

Edit operation finished
0 => action:error; sid:1342078252241; tid:1342078252241;

The main reason for the error was that the ID already existed in the database and thus, I could not “INSERT” the row.

Oh. I looked thru the logs more and I see …

exception 'Exception' with message 'Status of record [[object Object]] not found in incoming request' in dhtmlxConnector/codebase/dataprocessor.php:77
Stack trace:
#0 dhtmlxConnector/codebase/data_connector.php(44): DataProcessor->get_operation('[object Object]')
#1 dhtmlxConnector/codebase/dataprocessor.php(98): CommonDataProcessor->get_operation('[object Object]')
#2 dhtmlxConnector/codebase/base_connector.php(475): DataProcessor->process(Object(DataConfig), Object(DataRequestConfig))
#3 dhtmlxConnector/codebase/base_connector.php(398): Connector->render()
#4 data_scheduler_processor.php(26): Connector->render_table('aTable', 'Id', 'Field1, Fiel...')
#5 {main}

This appears in the middle of the logs before the INSERT statement. Not sure if it helps.

Unfortunately we can’t reconstruct the same issue locally.

According to the log records - it seems that client side sends invalid id to the server side, instead of real id it serializes some object ( object Object in logs )

try to update dataprocessor and datastore with attached one (40.4 KB)


Unfortunately, that didn’t help. I tried including the files before and after “dhtmlx.js” and still no dice.

Is there any way to force an update (instead of an insert)?

Could you maybe post the working sample you have so that I may try it on my end?
I am trying to programmaticaly insert, update and delete records from a DataStore connected to a backend MySQL database via DataProcessor and Connector.

Check the attached sample (35.5 KB) (77.3 KB)